Please help with On Error GoTo
Depending on whether your code is a subroutine or function, you can put
either this line of code...
Exit Sub
or this line of code...
Exit Function
immediately in front of your ErrorHandler label line to prevent your regular
code from falling through into your error handling code.
--
Rick (MVP - Excel)
"Accesshelp" wrote in message
...
Hello all,
In my code, I inserted an error trapping code in case an error has
occurred.
If there is an error, the code will jump to the error handler section and
execute the code in the ErrorHandler section. So the following is what I
have:
On Error Goto ErrorHandler
'The code in between
ErrorHandler:
Msgbox "An error has occurred please contact the IT department",
vbCritical
Somehow, the code from above executes the code in the ErrorHandler:
section
even there is no error. The code however did jump right into the
ErrorHandler section when there was an error.
Did I do something wrong? Please help.
Thanks.
|