how come when i put on erro goto error, then under the error: i put msgbox "error" to test things out, why does it message box me "error" even though theres been no error
Printable View
how come when i put on erro goto error, then under the error: i put msgbox "error" to test things out, why does it message box me "error" even though theres been no error
My guess is that you don't have Exit Sub before your error handler. Does your code look like this?
public Sub Foo()
on error GoTo error 'I wouldn't use a keyword for a label. How about "on error Goto Handler"?
'Do some stuff that may cause an error
ExtProc:
Exit Sub
error:
MsgBox "error"
resume ExtProc
End Sub
I'm not sure I understand your problem EXACTLY, but if I am right you have some code like this:
public Sub MySub()
'
on error Goto MyError
'
'Some code here...
'
MyError:
MsgBox "error"
End Sub
And everytime you run the code, you still get the messagebox telling you that an error has occurred. Am I right? If I am, the solution is to add an Exit Sub right before the MyError (or whatever yours is named) label. For example, try this:
public Sub MySub()
'
on error GoTo MyError
'
'Some code here...
'
Exit Sub
'
MyError:
MsgBox "error"
End Sub
Hope this helps,
Rippin