Time Sheet question

tfowlerusa

New Member
Joined
Mar 28, 2017
Messages
13
Good morning. I am trying to put a time sheet together and I am having issues with a few formulas. I have a Code Shift column that I am trying to use to sort time worked into a specific code. Code1 hours are 6am to 6pm, Code 2 6pm to 12am, and Code 3 from 12am to 6am. Then placing the time worked into the specific Code Shift Column. I have so problems with adjusting the times in the formula to put the times into the correct column. Also would love to have cells blank when there is not data to calculate. Any help would be appreciated. Thank you Todd

On Call Log.xlsx
ABCDEFGH
2 HoursCode Code 1 ShiftCode 2 ShiftCode 3 Shift
3EmployeeDateStart TimeStop TimeShiftTotal TimeTotal TimeTime
4Varon20-Jan12:00 PM12:18 PMCode 10:18  
58:30 AM9:30 AMCode 11:00  
612:20 PM1:20 PMCode 11:00  
71:45 PM2:00 PMCode 10:15  
83:00 PM3:45 PMCode 10:45  
93:45 PM4:00 PMCode 10:15  
104:00 PM4:15 PMCode 10:15  
115:00 PM6:00 PMCode 3  
126:45 PM7:15 PMCode 3  
1311:30 PM12:00 AMCode 1#VALUE!  
14Code 3  0:00
15Code 3  0:00
16Code 3  0:00
17Code 3  0:00
18Code 3  0:00
19Code 3  0:00
20Code 3  0:00
21Code 3  0:00
22Code 3  0:00
23Code 3  0:00
24Code 3  0:00
25Code 3  0:00
26Code 3  0:00
27Total Hours
Sheet1
Cell Formulas
RangeFormula
E4:E26E4=IF(AND(C4>=TIME(6,0,0), D4<TIME(18,0,0)), "Code 1", IF(AND(C4>=TIME(18,0,0), D4<TIME(24,0,0)), "Code 2", IF(OR(C4<TIME(6,0,0), D4>=TIME(24,0,0)), "Code 3", "Invalid Time")))
F4:F26F4=IF(E4="Code 1", TEXT(D4-C4, "h:mm"), "")
G4:G26G4=IF(E4="Code 2", TEXT(D4-C4, "h:mm"), "")
H4:H5,H7:H10,H13:H26H4=IF(E4="Code 3", TEXT(D4-C4, "h:mm"), "")
H6H6=IF(E6="Code 3", IF(ISNUMBER(C6), IF(ISNUMBER(D6), IF(C6 < D6, TEXT(D6 - C6, "h:mm"), TEXT(1 - C6 + D6, "h:mm")), ""), ""), "")
 
I used the first reply with formula and the Code 2 column is not working still. I am using Excel 365 so I am not sure if that is the issue. I am also formatting everything to custom hh:mm. Thank again for your help!

On Call Log.xlsx
BCDEFGHIJKLMN
16:00:0018:00:0018:00:010:00:000:00:016:00:00
2 HoursCode 1 ShiftCode 2 ShiftCode 3 ShiftCode 1Code 2Code 3
3DateStart TimeStop TimeTotal TimeTotal TimeTime
420-Jan12:0012:180:18  
58:309:301:00  
612:2013:201:00  
713:4514:000:15  
815:0015:450:45  
915:4516:000:15  
1016:0016:150:15  
1117:0018:001:00  
1218:4519:15 ############# 
1323:300:00 ############# 
1421-Jan1:002:00  1:00 
155:456:00  0:15
166:159:002:45  
17   
18   
19   
20   
21   
22   
23   
24   
25   
26   
27Total Hours Worked7:33#############1:15
28
Sheet1
Cell Formulas
RangeFormula
E4:E26E4=IF(AND(C4>=$I$1, C4<$J$1), MIN(D4, $J$1)-C4, "")
F4:F26F4=IF(AND(C4>$J$1, D4<=1), MIN(D4, $L$1)-C4, "")
G4:G26G4=IF(AND(C4>=$M$1, C4<=$N$1), MIN(D4, $N$1)-C4, "")
E27:G27E27=SUM(E4:E26)
J14J14=IF(AND(124>=$K$1, C12<$L$1), MIN(D12, $L$1)-MAX(C12, $K$1), "")
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Put 1 in cell D13 not 0.

Time 2023.xlsm
CDEFG
1
2 HoursCode 1 ShiftCode 2 ShiftCode 3 Shift
3Start TimeStop TimeTotal TimeTotal TimeTime
412:0012:180:18  
58:309:301:00  
612:2013:201:00  
713:4514:000:15  
815:0015:450:45  
915:4516:000:15  
1016:0016:150:15  
1117:0018:001:00  
1218:4519:15 0:30 
1323:300:00 0:30 
141:002:00  1:00
155:456:00  0:16
166:159:002:45  
177:331:001:16
2f
Cell Formulas
RangeFormula
E4:E16E4=MAX(0,MIN(D4,0.75)-MAX(C4,0.25,0))
F4:F16F4=MAX(0,MIN(D4,1)-MAX(C4,0.75,0))
G4:G16G4=CEILING(MAX(0,MIN(0.25,D4)-MAX(1/(24*60*60),C4,0)),1/(24*60))
E17:G17E17=SUM(E4:E16)
 
Upvote 0
Dave,

Thank you, I did use information from Post #10. I have 2 more questions. How would I handle cross shifts Line 17. Also Why am I getting values in cells that should not have any? I tried to put "" instead of a zero at end of formula and it give me #VALUE in cell. I also changed formatting to Custom h:mm AM/PM and it seems to work ok. Again I can not thank you enough.

On Call Log.xlsx
CDEFG
1Code 1 ShiftCode 2 ShiftCode 3 Shift
2 Hours6 am to 6 pm6 pm to Midnight6 pm to Midnight
3Start TimeStop TimeTimeTimeTime
412:00 PM12:18 PM0:180:000:00
58:30 AM9:30 AM1:000:000:00
612:20 PM1:20 PM1:000:000:00
71:45 PM2:00 PM0:150:000:00
83:00 PM3:45 PM0:450:000:00
93:45 PM4:00 PM0:150:000:00
104:00 PM4:15 PM0:150:000:00
115:00 PM6:00 PM1:000:000:00
126:45 PM7:15 PM0:000:300:00
1311:30 PM12:00 AM0:000:300:00
1412:15 AM1:15 AM0:000:001:00
1512:15 AM3:00 AM0:000:002:45
169:00 PM9:15 PM0:000:150:00
1710:00 PM1:00 AM0:000:000:00
1812:006:006:00
1912:006:006:00
2012:006:006:00
2112:006:006:00
2212:006:006:00
2312:006:006:00
2412:006:006:00
2512:006:006:00
2612:006:006:00
27Total Hours Worked16:487:159:45
Sheet1
Cell Formulas
RangeFormula
E4:E26E4=MAX(0,MIN(D4,0.75)-MAX(C4,0.25,0))
F4:F26F4=MAX(0,MIN(D4,1)-MAX(C4,0.75,0))
G4:G26G4=CEILING(MAX(0,MIN(0.25,D4)-MAX(1/(24*60*60),C4,0)),1/(24*60))
E27:G27E27=SUM(E4:E26)
 
Upvote 0
Try using Excel's tool Formulas Formula Evaluate to review how the formula works and to test edits to the formula.

Time 2023.xlsm
CDEFG
1Code 1 ShiftCode 2 ShiftCode 3 Shift
26 am to 6 pm6 pm to MidnightMidnight to 6 AM
3Start TimeStop TimeTimeTimeTime
412:0012:180:18  
58:309:301:00  
612:2013:201:00  
713:4514:000:15  
815:0015:450:45  
915:4516:000:15  
1016:0016:150:15  
1117:0018:001:00  
1218:4519:15 0:30 
1323:300:00 0:30 
140:151:15  1:00
150:153:00  2:45
1621:0021:15 0:15 
1722:001:00 2:001:00
18   
19   
20   
21   
22   
23   
24   
25   
26   
27Total Hours Worked4:483:154:45
28
2ff
Cell Formulas
RangeFormula
E4:E26E4=(C4>0)*MAX(0,(MIN(D4,0.75)-MAX(C4,0.25)))
F4:F26F4=LET(s,(C4>D4),(C4>0.75)*(IF(s,s-MAX(C4,0.75),D4-C4)))
G4:G26G4=LET(t,(C4>D4),IF(t,(D4-C4+t)-F4,AND(C4>0,C4<0.25)*(MIN(0.25,D4)-C4)))
E27:G27E27=SUM(E4:E26)
 
Upvote 0

Forum statistics

Threads
1,215,084
Messages
6,123,029
Members
449,092
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top