Hello,
im using this code for audit trail, but he is not archive old value. For example when I changed 5 to 10. In log I will have new value only.
Could you help me please? Im total newb in VBA.
Thank you!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rw As Long
Dim strAddress As String
Dim strUserName As String
Dim dtmTime As Date
Dim val As Variant
If Intersect(Target, Range("A:M")) Is Nothing Then Exit Sub
dtmTime = Now()
val = Target.Value
strAddress = Target.Address
strUserName = Environ("UserName")
Rw = Sheets("Log Sheet").Range("A" & Rows.Count).End(xlUp).Row + 1
With Sheets("Log Sheet")
.Cells(Rw, 1) = strUserName
.Cells(Rw, 2) = strAddress
.Cells(Rw, 3) = val
.Cells(Rw, 4) = dtmTime
End With
End Sub
im using this code for audit trail, but he is not archive old value. For example when I changed 5 to 10. In log I will have new value only.
Could you help me please? Im total newb in VBA.
Thank you!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rw As Long
Dim strAddress As String
Dim strUserName As String
Dim dtmTime As Date
Dim val As Variant
If Intersect(Target, Range("A:M")) Is Nothing Then Exit Sub
dtmTime = Now()
val = Target.Value
strAddress = Target.Address
strUserName = Environ("UserName")
Rw = Sheets("Log Sheet").Range("A" & Rows.Count).End(xlUp).Row + 1
With Sheets("Log Sheet")
.Cells(Rw, 1) = strUserName
.Cells(Rw, 2) = strAddress
.Cells(Rw, 3) = val
.Cells(Rw, 4) = dtmTime
End With
End Sub