Hello all,
I have the code doing what I want but cannot get the information that should paste over to the Audit Trail page table to add another row. It copies over a cell already containing previous data.
Help, please!!!
I have the code doing what I want but cannot get the information that should paste over to the Audit Trail page table to add another row. It copies over a cell already containing previous data.
Help, please!!!
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("A" & 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
End With
End If
End Sub