Error and Error Handling VBA Summary







































Error Handling Code line _______________________


Notes


On Error Resume Next



Makes code always carry on after error line. Clears the exception – So works time and time again, But retains infomation of last error in Err object



On Error GoTo Label/Line



Does not clear the exception. Just goes to the indicated Label or Line Number (Typically at that label or line number would be code lines for an error handling routine ) It is Prevented by default ( due to it not clearing the exception ) from working more than once



On Error GoTo 0



Does not clear the exception Disables any enabled error handler This Clears the Err object



On Error GoTo -1



Clears the exception (* Deactivates any enabled error handler) Does not disable any enabled error handler This Clears the Err object



Resume


Clears the exception (* Deactivates any enabled error handler) Does not disable any enabled error handler. Makes code try again at error line. ( Be careful as can lead to an infinite loop of retrying!!) Does not retain infomation of last error:Clears Err object



Resume Next



As Resume , but resumes after line which errored



Resume Label/Line Number



As Resume , but resumes at Label/Line number



* Deactivated means: "The trap is reset: but not currently working - It is "primed" ". It is enabled, but not activated.


Err : An object 6 Properties containing infomation about last error and 2 Methods, .Raise and .Clear


Erl : A Function returning line number of last error or 0 if no line number is present at erroring code line.


vbObjectError : Probably broken or no one remembers what it does - A plie of wank - forget about it!