On Error Statement

The On Error statement can be placed on your procedure to specify a section in the procedure to which the execution should jump when an error occurs. Here is an example:

Sub Test()

On Error GoTo HandleError

'normal code for the procedure goes here Exit Sub

HandleError:

'code for handling the error goes here Exit Sub

End Sub

If you want to make sure your own error handler doesn't kick in when you're debugging your code, select Tools C> Options C> General and enable the Break On All Errors option. This will allow you to see the root of the error and not your own error handler.

0 0

Post a comment