Hello Friends,
I am using the this VBA Code to format dates which are greater than or equal to today.
I require to add another condition i.e. if the adjacent cell (right one) is empty then only the code should format dates otherwise nothing should happen.
Any help would be appreciated.
Regards,
Humayun
I am using the this VBA Code to format dates which are greater than or equal to today.
I require to add another condition i.e. if the adjacent cell (right one) is empty then only the code should format dates otherwise nothing should happen.
Code:
Sub formatdates()
Dim rngCell As Range
Dim lngLstRow As Long
Dim strCol(1 To 9) As String
strCol(1) = "N"
strCol(2) = "P"
strCol(3) = "R"
strCol(4) = "T"
strCol(5) = "V"
strCol(6) = "X"
strCol(7) = "Z"
strCol(8) = "AB"
strCol(9) = "AD"
lngLstRow = ActiveSheet.UsedRange.Rows.Count
For I = 1 To 9
For Each rngCell In Range(strCol(I) & "4:" & strCol(I) & lngLstRow)
If rngCell.Value >= Now() Then
rngCell.Font.ColorIndex = 3
Else
rngCell.Font.ColorIndex = 1
End If
Next
Next I
End Sub
Any help would be appreciated.
Regards,
Humayun