Hello everybody,
I am hoping someone could help me out here. I am trying to create a code for an audit trail, and I am using the code below, which timestamps when the file is opened and closed. However, I was wondering if someone could tell me how to set it up so that it timestamps when someone makes changes to the specified worksheet. Here is the code I am currently using:
I am hoping someone could help me out here. I am trying to create a code for an audit trail, and I am using the code below, which timestamps when the file is opened and closed. However, I was wondering if someone could tell me how to set it up so that it timestamps when someone makes changes to the specified worksheet. Here is the code I am currently using:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Sheets("Log").Activate
Range("d2").Select
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Value = Environ("UserName")
ActiveCell.Offset(0, 1) = Date
ActiveCell.Offset(0, 2) = Time
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Sheets("Log").Activate
Range("A2").Select
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Value = Environ("UserName")
ActiveCell.Offset(0, 1) = Date
ActiveCell.Offset(0, 2) = Time
Application.ScreenUpdating = True
End Sub