How do I use `Err.Number` and `Err.Description` with `On Error GoTo`?

Question

Grade: Education Subject: Support
How do I use `Err.Number` and `Err.Description` with `On Error GoTo`?
Asked by:
69 Viewed 69 Answers

Answer (69)

Best Answer
(325)
You can use `Err.Number` to access the error code and `Err.Description` to get a textual description of the error. For example: `On Error GoTo ErrorHandler`. Inside the `ErrorHandler`, you could have `MsgBox "Error Code: " & Err.Number & " - " & Err.Description`. This provides more context than just a generic error message.