Calculating Hours worked minus lunch if lunch taken field says yes

nakiasl

New Member
Joined
Feb 12, 2021
Messages
9
Office Version
  1. 2013
Platform
  1. Windows
I'm trying to find a formula that will calculate the hours worked and only subtract 30 minutes for lunch if the column states yes lunch was take. if the column states no then should just calculate the hours worked with out 30 minutes for lunch. if this is not possible the alternative I'd be looking for is a formula that will only subtract 30 minutes for lunch if the hours worked is over 5 hours, if it is not over 5 hours then 30 minutes for lunch would not be subtracted.

I have this formula:

=IF(D5=0,,TEXT(IF(VALUE(TEXT(E5-D5,"h:mm"))>5,VALUE(TEXT(E5-D5,"h:mm"))-0.041667,(VALUE(TEXT(E5-D5,"h:mm"))-0.020833)),"h:mm"))

and it works for subtracting 30 minutes if hours worked is over 5, but if hours worked are under 5 it is till subtracting the 30 minutes.

below is what My sheet looks like. HELP PLEASE!!!

1641515376052.png
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi Nakiasl,

So the Shift Hours Worked is total elapsed but Total Hours Worked (Decimal format) and Total Hours Worked (Hours format) should reduce by 30 minutes if Lunch is "Yes"?

Note the first check is if the Punch Out time is less than the Punch In time which would indicate somebody worked over midnight do the Punch Out time has 1 day added for the calculation to work correctly.

Please also note all Hour:Minute formats should use Format, Custom [hh]:mm so if any time exceeds 24 hours it calculates correctly.

Nakiasl.xlsx
ABCDEFGHI
1NameDateIn PunchOut PunchTransferLunch Yes/NoTotal Hours Worked (Decimal format)Shift Hours WorkedTotal Hours Worked (Hours format)
2NakiaSl1/3/20228:3017:55Yes8.9209:2508:55
3NakiaSl1/4/20228:4519:00Yes9.7510:1509:45
4NakiaSl1/5/202212:1516:30Yes3.7504:1503:45
5NakiaSl1/6/20228:3014:40Yes5.6706:1005:40
6NakiaSl1/7/202216:1519:00No2.7502:4502:45
7NakiaSl1/8/20228:0011:00No3.0003:0003:00
Sheet1
Cell Formulas
RangeFormula
G2:G7G2=((IF($D2<$C2,($B2+1+$D2)-($B2+$C2),($B2+$D2)-($B2+$C2)))-(IF($F2="Yes",TIME(0,30,0),0)))*24
H2:H7H2=((IF($D2<$C2,($B2+1+$D2)-($B2+$C2),($B2+$D2)-($B2+$C2))))
I2:I7I2=G2/24
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,141
Members
449,066
Latest member
Andyg666

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