Hi All
I would like to fill a range of cells with color using a vba. The cells will be colored depending on the date. For example today's date is 27/08/2021 I need the cells in the row with a date that is 10 days or more earlier (17/08/2021) to be filled.
This is what I have so far however it seems to color every second row.
Any help or advise will be greatly appreciated.
Thank you
Private Sub CommandButton4_Click()
Dim TDateM As String
TDateM = Date
endrow = Range("a" & Rows.Count).End(xlUp).Row
For Each cell In Range("a1:a" & endrow)
If cell.Value < TDateM Then
cell.Range("$a$" & cell.Row & ":$m$" & cell.Row).Interior.ColorIndex = 6
End If
Next
End Sub
I would like to fill a range of cells with color using a vba. The cells will be colored depending on the date. For example today's date is 27/08/2021 I need the cells in the row with a date that is 10 days or more earlier (17/08/2021) to be filled.
This is what I have so far however it seems to color every second row.
Any help or advise will be greatly appreciated.
Thank you
Private Sub CommandButton4_Click()
Dim TDateM As String
TDateM = Date
endrow = Range("a" & Rows.Count).End(xlUp).Row
For Each cell In Range("a1:a" & endrow)
If cell.Value < TDateM Then
cell.Range("$a$" & cell.Row & ":$m$" & cell.Row).Interior.ColorIndex = 6
End If
Next
End Sub