MACRO LIBRARY

Error handling example

Free public access. No account or subscription required.

Files

Error handling example

Code

'You cannot put your error handling code in a different sub procedure. Instead, use _
    "Exit Sub" to quit the sub procedure where it would normally quit, were the error _
    handling code not present.
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Sub main()
On Error GoTo ErrHandler:
Debug.Print 1 / 0
Exit Sub
    
ErrHandler:
Debug.Print "Error handling!"
Debug.Print Err.Number
Debug.Print Err.Description
End Sub