Hello,
I am trying to get excel to go to my error handler if Esc is pressed whilst the macro is running. This is what I have so far but when I press Esc, Excel goes to the error handler and breaks on the first line with error 'User interrupt occurred' instead of running through the code in the error handler:
Code
On Error GoTo Error_Handler
Application.EnableCancelKey = xlErrorHandler
Error_Handler:
If Err = 18 Then
MsgBox "Macro exited...", vbExclamation, "Stopped!"
Else
Debug.Print "Line: " & Erl & " Desc: " & Err.Description
MsgBox "An error occurred, exiting macro...", vbCritical, "Error!"
End If
Display More
Any ideas please?
Also posted here:
https://www.mrexcel.com/forum/…pe-key-error-handler.html