OnError
- Last UpdatedJul 18, 2023
- 1 minute read
VBA's error-handling routine and specifies the line label of the error-handling routine. The line parameter refers to a label. That label needs to be present in the code or an error is generated.
Syntax
On Error { GoTo line | Resume Next | GoTo 0}
Example
On Error GoTo errHandler
Dim x as object
x.draw ' Object not set
..
Exit Sub
errHandler:
Print Err.Number, Err.Description
Resume Next