gravanoc
Active Member
- Joined
- Oct 20, 2015
- Messages
- 348
- Office Version
- 365
- Platform
- Windows
- Mobile
I have a variant variable that will store the user's response to an InputBox in which they are supposed to choose a range or press Cancel. Since Cancel makes the variable False, the Set statement could cause an error, so I use On Error Resume Next before the assignment statement, and then follow it on the next line with On Error GoTo 0. The problem occurs when I try to check Err.Number with an If statement (If Err.Number = 13 Then) since it always returns False. However, if I instead put On Error GoTo NextBlock in place of On Error Resume Next, it will properly recognize Err.Number in an If statement.
Is there a better way to do this?
Code:
Is there a better way to do this?
Code:
VBA Code:
On Error GoTo -1
On Error GoTo ErrNext
Set answer = Application.InputBox(Prompt:="Please select the cell with key phrase " & successfulAttempt & " in it, i.e. Problemes constates par le Client." _
& " If there are not hyphens (-) before each item, press Cancel. If the sheet is blank select A1.", Title:="Manual Select", Type:=8)
On Error GoTo 0
If Err.Number = 13 Then ' I could put ErrNext before this if statement if I wanted to and it would work correctly
ErrNext:
On Error GoTo -1