Lensmeister
New Member
- Joined
- Mar 27, 2006
- Messages
- 45
Morning all,
I have worksheet with about 50+ sheets that is on our server. I need to be able to see who changed what cell and on what sheet and when.
I found this code on here:
Initially it worked but just shows the cell reference number. Also it has to be pasted into each sheet in the workbook.
Is there another way to do this so that the code is in a module and logs to the "log" sheet with the sheet name as well please?
Many thanks in advance
I have worksheet with about 50+ sheets that is on our server. I need to be able to see who changed what cell and on what sheet and when.
I found this code on here:
Code:
Option Explicit
Const intUsernameColumn = 1
Const intCellRefColumn = 2
Const intNewValueColumn = 3
Const intTimestampColumn = 4
Private Sub Worksheet_Change(ByVal Target As Range)
Dim shtLog As Worksheet
Dim cll As Variant
Dim lngNextRow As Long
Set shtLog = ThisWorkbook.Sheets("Log")
For Each cll In Target.Cells
lngNextRow = shtLog.Cells.Find(What:="*", After:=[A1], Searchorder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
shtLog.Cells(lngNextRow, intUsernameColumn).Value = Environ("username")
shtLog.Cells(lngNextRow, intCellRefColumn).Value = cll.Address
shtLog.Cells(lngNextRow, intNewValueColumn).Value = cll.Value
shtLog.Cells(lngNextRow, intTimestampColumn).Value = Format(Now, "dd-mmm-yy hh:mm:ss")
Next cll
End Sub
Initially it worked but just shows the cell reference number. Also it has to be pasted into each sheet in the workbook.
Is there another way to do this so that the code is in a module and logs to the "log" sheet with the sheet name as well please?
Many thanks in advance