I have a column that has a list of different times, and I need to figure out how to write code to highlight every other hour block. I want to set a highlight for the group of cells in the 6:00 hour, the 8:00 hour, 10:00 and so on.
I've tried to set a counter, however given the way excel views times as though they were a date, I'm having problems.
Here is a sample of the data which is in Column A formatted Custom as "hh:mm:ss" and starting on row 4:
Here's what I have so far as a work in progress.
As you can see, I think I have everything except for figuring out how to add an hour. (And I've got to admit, I was proud of myself for coming up with the HighlightSwitch to only hit every other hour). But that adding an hour is killing me.
Thoughts? Any help would be very appreciated. Thanks!
I've tried to set a counter, however given the way excel views times as though they were a date, I'm having problems.
Here is a sample of the data which is in Column A formatted Custom as "hh:mm:ss" and starting on row 4:
HTML:
6:00 AM
6:40 AM
6:52 AM
7:04 AM
7:10 AM
7:11 AM
7:43 AM
7:51 AM
7:59 AM
8:07 AM
8:19 AM
8:52 AM
9:05 AM
9:06 AM
9:14 AM
Here's what I have so far as a work in progress.
HTML:
HourStartRow = 4
HighlightSwitch = 1
For i = 4 To ScheduleLastRow
If Schedule.Range("A" & i).Value > Schedule.Range("A" & HourStartRow).Value + 1 Then 'should be +1 hour
HourEndRow = i - 1
Else
End If
If Not HourStartRow = Empty And Not HourEndRow = Empty Then
If HighlightSwitch > 0 Then
HighlightSwitch = HighlightSwitch * (-1)
Schedule.Range(Cells(1, HourStartRow), Cells(1, HourEndRow)).Interior.ColorIndex = 6
HourStartRow = HourEndRow + 1
HourEndRow = Empty
Else
HighlightSwitch = HighlightSwitch * (-1)
HourStartRow = HourEndRow + 1
HourEndRow = Empty
Else
End If
Next
As you can see, I think I have everything except for figuring out how to add an hour. (And I've got to admit, I was proud of myself for coming up with the HighlightSwitch to only hit every other hour). But that adding an hour is killing me.
Thoughts? Any help would be very appreciated. Thanks!