Dan: The table in my previous posting had an error. Use these instruction
instead
The process I worked out is a little complicated, but it is the most
vertsitile. Shifts are probably different on the weekend than the week day
so a fixed formula will work out to be very complicated. I think it is
easier to do with buildingg a table. Make Sunday Midnight (Saturday night)
as hour 0 and then calculate the number of hours from Sunday midnight to the
hour of the shift. then lookup the hour in a table using vlookup. Here is
my table. Your table can be different.
Start Time Shift
0:00:00 Sunday 0:00 E
8:00:00 Sunday 8:00 D
16:00:00 Sunday 16:00 D
24:00:00 Monday 0:00 E
32:00:00 Monday 8:00 A
40:00:00 Monday 16:00 B
48:00:00 Monday 0:00 C
56:00:00 Tuesday 8:00 A
64:00:00 Tuesday 16:00 B
72:00:00 Tuesday 0:00 C
80:00:00 Wednesday 8:00 A
88:00:00 Wednesday 16:00 B
96:00:00 Wednesday 0:00 C
104:00:00 Thursday 8:00 A
112:00:00 Thursday 16:00 B
120:00:00 Thursday 0:00 C
128:00:00 Friday 8:00 A
136:00:00 Friday 16:00 B
144:00:00 Friday 0:00 C
152:00:00 Saturday 8:00 D
160:00:00 Saturday 16:00 D
168:00:00 Saturday 0:00 E
The table above have 4 columns starting in cell A1.
1) Column B - is just text information showing the day of the week
2) Column C - The start ime of the shift formated in time format
3) Column D - the shift letter which is is text. No formula
4) Column A - Formated in time format 38:00 which is total hours
this is a formula.
Cell A2 =C2
=IF(C3-C2>=0,C3-C2+A2,1+C3-C2+A2)
Then copy this formula down column A.
Column A is now total hours from Sunday midnight
the one in the above formula add 1 day so you don't get a negative number.
Time in excel for 8:00 AM is really the number .33333 which is 1/3 of a day.
Then if your shift start time is cell D1, and Date E1
The day of the week is function is weekday() which return 1 for Sunday.
Because you want Sunday to be 0 you have to subtract 1 one from this number.
=24*(weekday(E1)-1) which give the number of hours from Sunday to midnight
of the day you work
Now you have to add the time of the day which is simply your start time.
Excel throw in a simple problem that time is a fractional number of a day.
8:00 AM is really .3333333 (8 hours /24 hours). Your formula is now
=(24*(weekday(E1)-1))+(24*D1)
To make thing easier I would put this number in its own cell. For this
example F1. You could make it part of a larger formula.
Now the rest is a simple vlook() function.
=VLOOKUP(F1,A2

33,4)
This simple says to look up the hour in the table and return the 4 column
which is column D.