Hey guys,
So recently I used a thread I saw on here to create a code that will input a time and date whenever a cell value changes. I used it for one range (the first part of my code that I will post), but then when I added the second part it worked once and then stopped working all together. I even took out the whole second part and for some reason the first part wouldn't work at all. Any help would be appreciated. Thanks!
So recently I used a thread I saw on here to create a code that will input a time and date whenever a cell value changes. I used it for one range (the first part of my code that I will post), but then when I added the second part it worked once and then stopped working all together. I even took out the whole second part and for some reason the first part wouldn't work at all. Any help would be appreciated. Thanks!
Code:
Dim WorkRng As Range, CredWorkRng As Range
Dim Rng As Range, CredRng As Range
Dim xOffsetRow As Integer, xOffsetCol As Integer
'First Part
Set WorkRng = Intersect(Application.ActiveSheet.Range("J7"), Target)
xOffsetRow = 3
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In WorkRng
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(xOffsetRow, 0).Value = Now
Rng.Offset(xOffsetRow, 0).NumberFormat = "mm-dd-yyyy, hh:mm:ss"
Else
Rng.Offset(xOffsetRow, 0).ClearContents
End If
Next
Application.EnableEvents = True
End If
'Second Part
Set CredWorkRng = Intersect(Application.ActiveSheet.Range("U:U"), Target)
xOffsetCol = 1
If Not CredWorkRng Is Nothing Then
Application.EnableEvents = False
For Each CredRng In CredWorkRng
If Not VBA.IsEmpty(CredRng.Value) Then
CredRng.Offset(0, xOffsetCol).Value = Now
CredRng.Offset(0, xOffsetCol).NumberFormat = "mm-dd-yyyy"
Else
CredRng.Offset(0, xOffsetCol).ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub