Hello, can anyone help me with this please - the macro is deleting all dates older than 5 days even if the adjacent cell is not empty:
I have also tried if ISBLANK(RFA.Offset(0, 1)) but that didn't work either
tyvmia
VBA Code:
Sub DeleteOldDates()
Dim RFA As Range
Dim RFARng As Range
Dim CurrentDate
Dim tblTracker As ListObject
Dim lrow As Long
Set tblTracker = shTracker.ListObjects("tblTracker")
lrow = tblTracker.Range.Rows(tblTracker.Range.Rows.Count).Row
Set RFARng = Range("Z20:Z" & lrow)
CurrentDate = Date
Application.ScreenUpdating = False
On Error Resume Next
For Each RFA In RFARng
If RFA.Offset(0, 1) = "" And WorksheetFunction.WorkDay(RFA.Value, 5, Range("Holidays")) < CurrentDate Then
RFA.ClearContents
End If
Next RFA
Application.EventsEnable = True
Application.ScreenUpdating = True
End Sub
I have also tried if ISBLANK(RFA.Offset(0, 1)) but that didn't work either
tyvmia