Hello Everyone,
I'm trying to incorporate a code that will track all changes made to a worksheet. The code below works great, however, I can't get Target.Address to update when I insert a row.
For example, say if I put "test" in A4, and I insert a row, and "test" is now in A5...I can't get the Target.Address value in 'Log Sheet' to update accordingly


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
I'm trying to incorporate a code that will track all changes made to a worksheet. The code below works great, however, I can't get Target.Address to update when I insert a row.
For example, say if I put "test" in A4, and I insert a row, and "test" is now in A5...I can't get the Target.Address value in 'Log Sheet' to update accordingly



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