I need to run a macro on a spreadsheet daily that contains dates in column G.
If the date in this column matches today's date, highlight entire row color1. If it is one day before today's date, highlight rows color2. If it is tomorrow's date, highlight rows color3. I realize there are many ways this might be done, but my first approach went like this:
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
For Each Cell In Range("G2:G" & FinalRow)
If DateValue(Cell.Value) = DateValue(Date) Then
Cell.Interior.ColorIndex = 1
ElseIf DateValue(Date) = DateValue(Date) - 1 Then
Cell.Interior.ColorIndex = 2
ElseIf DateValue(Date) = DateValue(Date) + 1 Then
Cell.Interior.ColorIndex = 3
End If
Next Cell
The problem with this is that Monday and Friday present a problem because Friday's date + 1 is Saturday; Monday's date - 1 is Sunday. The macro needs to include workday dates only, excluding weekend dates.
I am attaching an example of what I would like the result to look like, assuming today was 11/14/2014, and you can see the format of the date I must work with. It accounts for 11/13, 11/14, & 11/17 (skips weekend of 15th, 16th).
Bookmarks