Hello all,
I have a worksheet change code that inputs the date when a cell in my range is edited and clears it when the range is cleared, however, I am looking to change it where only the value of "Y" inputs the date, and anything else would clear it. I'm sure I'm pretty close with some of my attempts, but any assistance would be greatly appreciated.
I have a worksheet change code that inputs the date when a cell in my range is edited and clears it when the range is cleared, however, I am looking to change it where only the value of "Y" inputs the date, and anything else would clear it. I'm sure I'm pretty close with some of my attempts, but any assistance would be greatly appreciated.
VBA Code:
Set WorkR = Intersect(Application.ActiveSheet.Range("I9:I100000"), Target)
xOffsetColumnR = 1
If Not WorkR Is Nothing Then
Application.EnableEvents = False
For Each Rng In WorkR
If Not VBA.IsEmpty(Rng.Value) Then 'changes for all values
'If (Rng.Value) = "Y" Then 'only deletes blanks
ActiveSheet.Unprotect
Rng.Offset(0, xOffsetColumnR).Value = Now
Rng.Offset(0, xOffsetColumnR).NumberFormat = "mm/dd/yyyy"
Target.Offset(1, 0).EntireRow.Hidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingRows:=True, _
AllowInsertingRows:=True
Else
ActiveSheet.Unprotect
Rng.Offset(0, xOffsetColumnR).ClearContents
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingRows:=True, _
AllowInsertingRows:=True
End If
Next
Application.EnableEvents = True
End If