I'm trying to have some inputboxes for a byte-sized number, and when there's an error I want to display a msgbox saying "Please Enter a Number Between 1 and 10.". Here's what I have so far:
What happens when I run the above code is that the error handling performs correctly ONLY ONCE. On the second error, I get a run-time error window. This happens for both mismatch and overflow errors.Sub Example() Dim CodeLength As Byte, CodeRange As Byte CodeLengthInput: On Error GoTo CodeLengthError CodeLength = InputBox("Enter Code Length") CodeRangeInput: On Error GoTo CodeRangeError CodeRange = InputBox("Enter Code Range") GoTo InputsOK CodeLengthError: MsgBox ("Please Enter a Number Between 1 and 10.") GoTo CodeLengthInput CodeRangeError: MsgBox ("Please Enter a Number Between 1 and 10.") GoTo CodeRangeInput InputsOK: End Sub
The confusing part is that if I put in an incorrect value for the first inputbox, get the error msgbox, put in a correct value, then put an incorrect value for the second inputbox, then I still don't get a second error msgbox - the error msgbox will only appear once no matter what.
Anybody have an idea on what I'm doing wrong? How do I get error handling to work correctly every time?