Is there a "generic" Error Handling method

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

Guest

Is there an Error Handling method that can be used in a generic sense? i.e.
a statement that can be included in any sub. that will handle any error to
some degree.

Thanks,
Brad K
 
Of course everyone has there own but you could use something like:

On Error GoTo ErrorHandler

'Your code

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' Close and tidy up
Tidy:

'' Reset variables
Set cnn = Nothing
Set cmd = Nothing
ActiveSheet.Protect
Application.EnableEvents= True
' etc --- comment out the ones that don't apply
Exit Sub

'' - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ErrorHandler:

MSG ="Error Number: " & Err & _
Chr(10) & "Error Description: " & Error()

MsgBox NSG, vbInformation, "ERROR:"
GoTo Tidy

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