|
On the next
line, directly underneath Dim tempCell as Range, type the
following comment.
‘
The following line creates an inputBox and assigns the value to
userInput
On the line
beneath this, type userInput = InputBox("
Please Enter a Number", "Input")
You should
now be able to click the button on
the visual basic window menu to run the incomplete macro.
You should see the following inputBox.

Click the
x in the upper right of the InputBox to close it.
There may be
a problem comparing a Variant variable type (like
userInput) to a cell value, because we are not sure what a type
of value the Variant holds. To overcome this, you should
position the cursor directly under the statement
Dim
tempCell As Range
and type
Dim myInput As Integer
This will
declare an integer value that we can use to compare with each
cell value.
Next,
position your cursor on the next line after
userInput
= InputBox(" Please Enter a Number", "Input")
and type
the comment
‘
The next line tests to see if the input is a number
Then, on the
following line type
If
IsNumeric(userInput) Then myInput = myInput + userInput
The macro
code should now look like this.

|