track row changes with date and time stamp
to do this you'll need to keep a copy of the sheet. This is because once a
cell value is changed, you won't know what it was
The copy will give you this.
so use the change event to do two things....write the change to the history
file and also update the copy
so I have three sheets ... Main, MainCopy and MainHistory
whenever a change is made to Main, then MainCopy is updated and so is
MainHistory.
This is the code behind Main:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim saddress As String
saddress = Target.Address
If Worksheets("MainCopy").Range(saddress).Value < Target.Value Then
With Worksheets("MainHistory").Range("A" & Rows.Count).End(xlUp).Offset(1)
.Value = Cells(1, Target.Column) ' header
.Offset(, 1) = Worksheets("MainCopy").Range(saddress).Value 'old value
.Offset(, 2) = Target.Value 'new value
.Offset(, 3) = Environ$("username") 'user
.Offset(, 4) = Now
End With
Worksheets("MainCopy").Range(saddress).Value = Target.Value
End If
End Sub
"HarryisTrying" wrote:
I looked at a similiar request called "Track changes by row in different
worksheet - History tracking" that was posted previously and tried to modify
it.
What I would like to do is take my 37 column spreadsheet with a header row
and anytime any cell in a row is changed write the original row to the
History Sheet with the user ID (network) and a date and time stamp. I would
like the header row to be in the History file. If the ultimate was available
the changed cell(s) would be highlighted with a different color.
--
Thank You
|