I am so accustomed to Excel dates and times I had to use them in the
Schedule entries. I also only used eight crews. My workbook can be downloaded from
https://www.dropbox.com/s/k5mgpuraeh4fxi9/treatlightly_gantt.xlsx?dl=0
The Schedules sheet:
I copied the times from
Schedule to
Visuals, while at the same time I subtracted three hours from those times—'3/24' is three hours to Excel.
| B | C | D | E | F | G | H | I | J | K | L |
---|
| | | | | | | | | | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
Week 1 | Week 2 | Week 3 | Week 4 | | | | | | | | |
| | | | | | | | | | | |
Crew 1 | | | | | | | | | | | |
Crew 2 | | | | | | | | | | | |
Crew 3 | | | | | | | | | | | |
Crew 4 | | | | | | | | | | | |
Crew 5 | | | | | | | | | | | |
Crew 6 | | | | | | | | | | | |
Crew 7 | | | | | | | | | | | |
Crew 8 | | | | | | | | | | | |
<tbody>
[TD="align: center"]4[/TD]
[TD="bgcolor: #EBEBEB"]For date[/TD]
[TD="bgcolor: #FFF5D7, align: right"]18/06/2018[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]5[/TD]
[TD="bgcolor: #EBEBEB"]Week Number[/TD]
[TD="align: right"] 3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #EBEBEB, align: right"]Start[/TD]
[TD="bgcolor: #EBEBEB, align: right"]Finish[/TD]
[TD="bgcolor: #EBEBEB, align: right"]Start[/TD]
[TD="bgcolor: #EBEBEB, align: right"]Finish[/TD]
[TD="bgcolor: #EBEBEB, align: right"]Start[/TD]
[TD="bgcolor: #EBEBEB, align: right"]Finish[/TD]
[TD="bgcolor: #EBEBEB, align: right"]Start[/TD]
[TD="bgcolor: #EBEBEB, align: right"]Finish[/TD]
[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]6:00[/TD]
[TD="align: right"]14:00[/TD]
[TD="align: right"]9:00[/TD]
[TD="align: right"]19:00[/TD]
[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]5:00[/TD]
[TD="align: right"]13:00[/TD]
[TD="align: right"]17:00[/TD]
[TD="align: right"]23:00[/TD]
[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]7:00[/TD]
[TD="align: right"]13:00[/TD]
[TD="align: right"]17:00[/TD]
[TD="align: right"]23:00[/TD]
[TD="align: right"]4:00[/TD]
[TD="align: right"]9:00[/TD]
[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]9:00[/TD]
[TD="align: right"]19:00[/TD]
[TD="align: right"]7:00[/TD]
[TD="align: right"]13:00[/TD]
[TD="align: center"]13[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]9:00[/TD]
[TD="align: right"]19:00[/TD]
[TD="align: right"]17:00[/TD]
[TD="align: right"]23:00[/TD]
[TD="align: center"]14[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]17:00[/TD]
[TD="align: right"]23:00[/TD]
[TD="align: right"]9:00[/TD]
[TD="align: right"]19:00[/TD]
[TD="align: right"]7:00[/TD]
[TD="align: right"]13:00[/TD]
[TD="align: center"]15[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]4:00[/TD]
[TD="align: right"]9:00[/TD]
[TD="align: center"]16[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]4:00[/TD]
[TD="align: right"]9:00[/TD]
</tbody>
Visuals
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]C5[/TH]
[TD="align: left"]=WEEKNUM(
GanttDate - 1) - 22[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]E9[/TH]
[TD="align: left"]=IF(
Schedule!C6 = "", "", (Schedule!C6 < 3 / 24) + Schedule!C6 - 3 / 24)[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]F9[/TH]
[TD="align: left"]=IF(
Schedule!D6 = "", "", (Schedule!D6 < 3 / 24) + Schedule!D6 - 3 / 24)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Workbook Defined Names[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Name[/TH]
[TH="align: left"]Refers To[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]GanttDate[/TH]
[TD="align: left"]=Visuals!$C$4[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
In C5 I corrected for my week beginning on Sunday by subtracting 1 from the date. I found which section of the table to use by subtracting 22 from the WEEKNUM.
I set up the Gantt chart by formatting the cells with a custom number: ";;;" (three semicolons, no quotation marks). This stops any entries from showing in the worksheet or printing, but the entries still appear in the formula bar. This does not affect the conditional formatting: a fill color.
Visuals sheet
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]O8[/TH]
[TD="align: left"]=REPT(
O$7, AND(ROUND($N8 - 3/24, 6) >= IFERROR(ROUND(INDEX(Weeks, MATCH(O$7, $D$9:$D$16, 0), 1, WeekNumber), 6), 0),
ROUND($N8 - 3/24, 6) <= IFERROR(ROUND(INDEX(Weeks, MATCH(O$7, $D$9:$D$16, 0), 2, WeekNumber), 6), 0)))[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]N9[/TH]
[TD="align: left"]=N8 + TIME(
0, 30, 0)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Workbook Defined Names[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Name[/TH]
[TH="align: left"]Refers To[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]WeekNumber[/TH]
[TD="align: left"]=Visuals!$C$5[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]Weeks[/TH]
[TD="align: left"]=(
Visuals!$E$9:$F$16, Visuals!$G$9:$H$16, Visuals!$I$9:$J$16, Visuals!$K$9:$L$16)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
The named formula, Weeks, has four areas, each of eight rows and two columns.
=( range_1, range_2, range_3, range_4)
I used INDEX formulas in the chart to do the lookups:
INDEX( lookup_range, row_to_lookup, column_to_lookup, area_to lookup )
I threw an IFERROR around the INDEX to correct for the unsuccessful lookups. Everything worked except for the comparison at 02:00. I found I was comparing two floating point values that differed at some decimal digit. I tried rounding to six places gave me the proper correction for the floating point error and I did not try to fine-tune the rounding. I was happy with a first-guess success.
The AND evaluates to TRUE or FALSE. Within the REPT formula, TRUE is coerced to 1 and FALSE to 0.
=REPT( string, n_times )
The whole formula tells Excel to repeat the crew name one time if the AND evaluates to TRUE and to repeat the name zero times if the AND evaluates to FALSE.
In Visuals!O8:V48 I used conditional formatting, assigning each crew name to a different color.