Can I end a sub on error?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need some code so that if the sub errors anywhere the sub simply ends
instead of giving the user the "Debug or End" message box. Please help.
 
You can use On Error Goto something like this...

Sub WhatEver()
On Error GoTo ExitSub
'Your Code

ExitSub:

End Sub
 
One way:

Public Sub AbortOnError()
On Error GoTo ErrHandler

'Your code here

Exit Sub
ErrHandler:
'Handle Error, Clean up, or just exit
End Sub
 

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

Back
Top