Hello,
I cannot remember how to write the code for this one thing.
I have a workbook with tables and have a sheet holding the Audit trail data. All is pulling correctly, but I need to have it identify the text in the first column of data when it finds the address that is identifying as the changed data.
The identity of the target.address is always changing because it is accounting for all changes, but I need the first column text for each entry. Can anyone help me sate this correctly.
Help?
I cannot remember how to write the code for this one thing.
I have a workbook with tables and have a sheet holding the Audit trail data. All is pulling correctly, but I need to have it identify the text in the first column of data when it finds the address that is identifying as the changed data.
The identity of the target.address is always changing because it is accounting for all changes, but I need the first column text for each entry. Can anyone help me sate this correctly.
Help?
VBA Code:
Dim PreviousValue
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
Dim ws As Worksheet
Set ws = Sheets("Audit Trail")
i = ws.Range("F" & Rows.Count).End(xlUp).Row + 1
If Target.Value <> PreviousValue Then
With ws
.Range("B" & i).Value = FormatDateTime(Now, vbShortDate)
.Range("C" & i).Value = FormatDateTime(Now, vbLongTime)
.Range("D" & i).Value = Environ$("username")
.Range("E" & i).Value = ActiveSheet.Name
.Range("F" & i).Value = Target.Address
.Range("G" & i).Value = PreviousValue
.Range("H" & i).Value = Target.Value
'.Range("I" & i).Value =
End With
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PreviousValue = Target.Value
End Sub