Using VBA to track changes in a worksheet - help! Event procedure??
Anita,
No problem, use the Worksheet_Change event in the code for the sheet you
want to "track" (right click on the sheet tab and select the menu item to
add code to that sheet)
The code below writes the change to a sheet called "Log"
The row used to write the last change is stored in cell B1 and is
incremented each time the event fires.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Lastrow As Long
Lastrow = ActiveWorkbook.Sheets("Log").Range("B1").Value
'Write the Change
ActiveWorkbook.Sheets("Log").Cells(Lastrow + 1, 1) = "Sheet (name) - Row " &
Target.Row & " - Column " & Target.Column & " changed to: " & Target.Value
'Increase the LastRow value by 1
ActiveWorkbook.Sheets("Log").Range("B1").Value = Lastrow + 1
End Sub
Good luck
"a" wrote in message
link.net...
Hi,
Is there a way to track changes made to a worksheet using VBA?
I was thinking that perhaps there was an event procedure. I envision
that the change could be displayed on a hidden sheet when a change is
made - similar to the tracking changes tool but without sharing a
workbook.
I'm on a deadline with this one and so any help would be greatly
appreciated. I've asked about this issue before and haven't received
any replies and so I'm thinking that maybe this cannot be done.
Thanks in advance for any help,
anita
|