OK, to summarize.
Text goes between double quotes. Variables don't need to be double quoted. Text and variables are concatenated by the Ampersand eg &.
If avalable I use the application version of a worksheetfunction because when running code with the Worksheetfunction and an error arises your code goes into Debug while
using the application version your code runs further but you can trap the error using IsError.
That being said here's something to study on.
In a worksheet module.
Private Sub CommandButton1_Click()
AddThreeNumbers
End Sub
In a standard module.
Sub AddThreeNumbers()
Dim myValue As Long, myValue2 As Long, myValue3 As Long
myValue = Application.InputBox("Enter first integer", , , , , , , 1)
myValue2 = Application.InputBox("Enter second integer", , , , , , , 1)
myValue3 = Application.InputBox("Enter third integer", , , , , , , 1)
MsgBox "The sum of " & myValue & ", " & myValue2 & " and " & myValue3 & " is " & _
Application.Sum(myValue, myValue2, myValue3), vbOKOnly, "My Own Adder"
End Sub
Bookmarks