-
Solved: Need to log macro errors
As to avoid relying on users to report macro error handled messages to the administrator, I'd like to also log the error type, date and time to a hidden sheet.
Does anyone use a method such as that and have a pre-written code sample they would be willing to share ?
Thanks
-
If VBA error messages are suppressed, how is the user to know that their results are wrong?
-
HI mikerickson,
Sorry that I didn't explain well. - I'm not suppressing errors. I have error handlers that report to the user with a message box. I just don't want to to rely on the user to report the error to me. -- The only reason I want the log sheet hidden is because some users get the bright idea that they are better off if I am not made aware that they have been experiencing errors.
-
Add a hidden worksheet to the workbook and add code to your error handler logging the error and the routine that errored.
Something like
[vba]Sub mySubOne()
On Error Goto Handler
' code
Exit Sub
Handler:
With ThisWorbook.Sheets("error Log").Range("A65536").End(xlup).Offset(1,0)
.Cells(1,1) = Now
.Cells(1, 2) = Err
.Cells(1, 3) = Error
.Cells(1, 4) = "mySubOne"
End With
' handle error
Exit Sub[/vba]
-
Perfect - Exactly what I was after
Thanks mikerickson
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules