Hi,
I had a code which auto update time & date on Col E
and last modified userid on col F.
Possible to rec which is the last modified cell?
<tbody>
</tbody>
I had a code which auto update time & date on Col E
and last modified userid on col F.
Possible to rec which is the last modified cell?
A | B | C | D | E | F |
abc | def | ghi | jkl | 8/9/2019 5:03:51 PM | C:\Users\TOM , update Cell A, B, C,D |
<tbody>
</tbody>
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
' Code to put the date of the latest update following a change in the corresponding cell in column F
Dim WorkRng As Range, roww As Long
Dim rng As Range
Set WorkRng = Intersect(Range("A:D"), Target)
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each rng In WorkRng
roww = rng.Row
If Not rng.Value = "" Then
Cells(roww, "E").Value = Now
Cells(roww, "E").NumberFormat = "dd-mm-yyyy, hh:mm:ss"
Cells(roww, "F").Value = Environ$("Userprofile")
Else
Cells(roww, "E").ClearContents
Cells(roww, "F").ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub