I've created a schedule in Excel and am using conditional formatting to control the generation of a Gantt chart. The sheet is formatted with a start time in column B and an end time in column C. I have in row
2 a series of times, in five minute intervals. I then have the following formula in the intersecting cells
=IF(StartTime <= CurrentTime,IF(EndTime > CurrentTime,10,0),0) For example:
B3 = 7:00 PM - manually entered
C3 = 8:00 PM - manually entered
E2 = 7:00 PM - manually entered (F2:BL2 = (Col-1)+Time(0,5,0) to give me the five minute intervals)
E3 = =IF($B3 <=E$2,IF($C3>E$2,10,0),0)
I then use conditional formatting to control the highlighting of cell E3:BL66 to draw the lines in my Gantt chart.
My problem is that - sometimes - I wind up with the line extending one cell too far. For example, on row 32 I have an event that runs from 8:00 PM to 9:00 PM. This corresponds to:
B32 = 8:00 PM - manually entered
C32 = 9:00 PM - manually entered
Q2 = 8:00 PM - calculated as described above through AC2 = 9:05 PM, also calculated
Q32 [=IF($B32 <=Q$2,IF($C32>Q$2,10,0),0)] through
AC32 [=IF($B32 <=AC$2,IF($C32>AC$2,10,0),0)]
The expected result is that cells Q32 through AB32 are calculated to a value of 10 and AC32 is calculated to a value of 0. In this particular case, I get the expected results.
In row 41, I have an event that runs from 9:00 PM to 10:00 PM, so I have the following values:
B41 = 9:00 PM - manually entered
C41 = 10:00 PM - manually entered
AC2 = 9:00 PM - calculated as described above through AO2 = 10:05 PM, also calculated
AC41 [=IF($B41 <=AC$2,IF($C41>AC$2,10,0),0)] through
AO41 [=IF($B41 <=AO$2,IF($C41>AO$2,10,0),0)]
The expected result is that cells AC41 through AN41 are calculated to a value of 10 and AO41 is calculated to a value of 0. In this particular case, AC41 through AN41 are calculated correctly; however, AO41
is calculated to a value of 10.
The interesting thing is that if I copy the manually entered time from cell C41 (10:00 PM) and paste it into cell AO41, I get the expected result! This suggests to me that the formula I am using to calculate
my time intervals [=AO2+TIME(0,5,0)] has a rounding error. Is there an alternative calculation that I can use, or some sort of wrapper function that can be used to compensate for any rounding that may occur?
It's also interesting to note that I initially entered all the times manually (including those in row 2) and observed the same behavior. That's when I implemented the calculation to automate the time interval
population. That's when I discovered that I could "solve" the problem by copying the time value from my "End" time to the appropriate cell in row 2.
Any help is appreciated. I'd be happy to send you a copy of the spreadsheet, if it would help!
Thanks!