On Error GoTo 0

This statement is the default error handler which interrupts execution and displays a dialog box.

Public Sub MySubroutine() 
    On Error GoTo 0

This is an example of the error message that is displayed:
SS

Public Sub DefaultErrorHandler() 
    On Error GoTo 0
'do something
    Charts("Chart 1").Activate 'this generates a run-time error
'execution stops and a dialog box is displayed
End Sub

If you switch to a different type of error handling you can switch back to the default by using the "On Error Goto 0" statement.


Err Object

There is no need to include the following line of code at the end of a procedure (or function) as error handling in a procedure (or function) is automatically disabled when the procedure (or function) exits.
Resets the Err object and resets the Err.Number to zero.

   On Error GoTo 0 
End Sub

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext