I just started learning VBA and I am trying to ask user to input
a number between 1 and 1000, and I wrote the following code:
----------------------------------------------------------------------------------------
Sub Simu()
Dim Iter As Variant
Dim Msg As String
Dim Ans As Integer
EnterAgain:
'if any run time error happens, excute BadEntry
'Ask user to enter a number between 1 to 1000"
'if nothing entered, stop the procedure
'if the number entered is not between 1 and 1000, treat it as bad entry
'if the number entered is valid, call reset function and start procudure
'this part works fine
'if a bad entry found, take action
'ask the user if they want to enter a valid number again
'Here is the confusing part...when I test the code, the msgbox always pop up twice
'even I choose yes...
-------------------------------------------------------------------------------------------------------------
Everything works fine except that the yes/no msgbox will always pop up twice
before the inputbox pops up. That means Excel will ask twice if the user want to enter
a number again...Can anyone help?
Bookmarks