View Full Version : Solved: Need to log macro errors
frank_m
11-20-2011, 02:19 PM
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
mikerickson
11-20-2011, 02:40 PM
If VBA error messages are suppressed, how is the user to know that their results are wrong?
frank_m
11-20-2011, 02:57 PM
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.
mikerickson
11-20-2011, 03:33 PM
Add a hidden worksheet to the workbook and add code to your error handler logging the error and the routine that errored.
Something like
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
frank_m
11-20-2011, 03:53 PM
Perfect - Exactly what I was after :thumb
Thanks mikerickson (http://www.vbaexpress.com/forum/member.php?u=10706) :friends:
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.