To run a macro when the Error event occurs, set the OnError property to the name of the macro.
You can use an Error macro to display a general message whenever a run-time error occurs. However, macros can’t return the error code and determine which error occurred, so you typically use event procedures with this event.
You can’t use the CancelEvent action in an Error macro.
Error Event — Event Procedures.