Create an Excel Input Box to Add Values and Display a Total
Question details
The user wants to enter values in Excel, add them like a calculator, and show the total in another cell.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Enter several numbers and display their sum in a worksheet cell, optionally using a pop-up input box.
- Observed behavior
- The desired result is a total that updates as values are entered.
Choose a worksheet cell for the total and decide whether you need a pop-up or can enter numbers directly into cells. To use the VBA option, open the workbook in a desktop version of Excel that supports macros.
Add numbers with a VBA input box in Excel
Use this option to enter numbers one at a time in a pop-up and show the running total in cell B1.
The macro starts a new total each time it runs. It updates B1 after each entry and stops when you select Cancel.
In Excel, open the target workbook and choose Developer > Visual Basic. If the Developer tab is hidden, enable it in Excel's ribbon settings.
In the VBA editor, select Insert > Module and paste this code: Sub AddValues() Dim entry As Variant Dim total As Double Dim target As Worksheet Set target = ActiveSheet total = 0 target.Range("B1").Value = total Do entry = Application.InputBox("Enter a number, or select Cancel to finish:", "Add values", Type:=1) If VarType(entry) = vbBoolean Then Exit Do total = total + CDbl(entry) target.Range("B1").Value = total Loop End Sub
Choose File > Save As and select Excel Macro-Enabled Workbook (*.xlsm) to retain the macro.
Return to the worksheet where you want the total, choose Developer > Macros, select AddValues, and click Run. Enter each number and select OK; select Cancel when finished. The total appears in B1.

Use a SUM formula instead of a pop-up
Use a worksheet range when you want a running total without creating a macro.
Add values with a running total in WPS Spreadsheets
Use WPS Spreadsheets to enter numbers in a worksheet range and display their sum in another cell. This formula-based approach does not require a pop-up or macro.
- 1. Open a spreadsheet: Open WPS Office, select Spreadsheets, and create a blank workbook or open an existing one.
- 2. Set up the total: Select cell B1, type =SUM(A1:A10), and press Enter.
- 3. Enter your numbers: Type values into cells A1 through A10 and check the updated total in B1.
- 4. Save the workbook: Choose File > Save As and select an Excel-compatible format such as XLSX.

Frequently Asked Questions
How do I stop the Excel input box?
Select Cancel in the input box. The macro stops and leaves the current total in B1.
Can I display the total in a different cell?
Yes. In the VBA editor, replace both instances of "B1" with the cell address you want to use, such as "C1".
Will the macro keep the previous total when I run it again?
No. This macro resets the total to zero and overwrites B1 each time you run it.
Why should I save the workbook as an XLSM file?
The Excel Macro-Enabled Workbook format retains VBA macros. Choose File > Save As and select *.xlsm before closing the workbook.
Can I add values without using VBA?
Yes. Enter =SUM(A1:A10) in B1, then type your numbers in A1 through A10. The total updates automatically.




