Hi all. Beginner working with VBA, and pulling out my teeth. I need to compile some code that accomplishes a number of things:
- Asks the user for a number, with Do loops that keep prompting until correct data is entered (must be numerical, must not be nothing, must be non-negative)
- Use a For loop that goes from 1 to this number
- Then asks for codes (listed in a reference sheet), must loop until a code listed in the sheet is entered, that corresponds to the number
- Finally, must display total cost attached to sum of the codes
I also need to use a variant variable for each input prior to error testing, and once error testing is done, I must assign it to the correct variable type.
This is as far as I've gotten:
Public Sub ProductsPurchased()
productCount = InputBox("Please enter the number of different products purchased.")
Do
If IsNumeric(productCount) = False Then
MsgBox "You have not entered a numerical value. Please try again."
Else
IsNumeric (productCount) < 0
MsgBox "You have entered a number less than or equal to zero. Please try again."
End If
Loop Until IsNumeric(productCount) And productCount > 0
End Sub
I am almost entirely lost. Please, help.
Bookmarks