Centralised error handler

C

C.Nieboer

Hello,

Maybe this looks kind a weird, because there are a lot of topics about
this isue.
Anyway I hope somone can give me a clear explanation if it is possible
(and how), or it isn't.
In most of the topics i saw questions about error handlers within error
handlers.
Or the topics are from 1997, so i think there is a lot different right
now.

I have round 8 procedures who will run with one button.
This is my errorhandler code:
Public Sub Errorhandler()
On Error GoTo handleCancel
Application.EnableCancelKey = xlErrorHandler

For X = 1 To 1000000 ' Do something 1,000,000 times (long!)
' do something here
Next X

handleCancel:
If Err = 18 Then
If MsgBox("Do you want to quit?", vbYesNo) = vbYes Then
GoTo Ending
Else
Resume
End If
End If
Ending:

Under Ending there normally is a code who protect my sheets again.
My question is can i make a procedure with this errorhanler, so this
handler will be active all the time when the macro is running??

I couldn't found somthing like that in other posts, or it was so
complex i don't get it anymore.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top