Lonemascot
New Member
- Joined
- Apr 28, 2015
- Messages
- 14
Hi all
This works if the cell is physically changed in column E.
However, if the contents of column E are only updated through their own cell references (say on another sheet) then this code doesn't pick up that the contents have changed in column E.
Any ideas to tweak so it does?
This works if the cell is physically changed in column E.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'add date when status changes
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("e:e"), Target)
xOffsetColumn = -1
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In WorkRng
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, xOffsetColumn).Value = Now
Rng.Offset(0, xOffsetColumn).NumberFormat = "dd/mm/yyyy"
Else
Rng.Offset(0, xOffsetColumn).ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub
However, if the contents of column E are only updated through their own cell references (say on another sheet) then this code doesn't pick up that the contents have changed in column E.
Any ideas to tweak so it does?