IF formula

Nunya1

New Member
Joined
Sep 3, 2019
Messages
31
I am doing timesheets and the following is the layout

E F G H I J
Start Break Finish Normal Hours Time & Half Double Time
08:30 1:00 19:30 8 3 2

Under the H cell I use this formula =IF(((G5-F5-E5)*24)>8,8,(G5-F5-E5)*24) to calculate the hours and to stop them at 8

Under the I cell I have this formula =IF(((G5-F5-E5)*24)>8,((((G5-F5-E5)*24)-8)*1.5)) to calculate the remainder of the hours at time and a half (X1.5)

Under the J Cell I have this formula =IF(((G5-F5-E5)*24)>8,((((G5-F5-E5)*24)-8)*1.5)>2)*2 to calculate the remainder as double time

What I need is the I cell (time and a half) to work similar to the H cell so I need it to take the remainder of the hours worked which in this example is 2 hours multiply it by 1.5 (which works in the formula I have used) now I need it to stop at 2 and then I need the rest of the hours which would be 1 to multiply in the J cell to double time (x2)

Can anyone help please :eeek:

TIA
 
Re: IF formula help

Ok so the timesheets were tested and an issue has been raised with them if the guys put in they work 8 hours normal and 1.5 hours at 1.5 times it is then giving a minus figure in the double time field, how can I fix this? (if the 1.5 time column doesn't show 2 that is when it puts the 2 x column into minus)
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Re: IF formula help

OT 2 was asuming 1.5 time meant there wa also 2.0 time so I've added a MAX

ABCDEFGHIJK
DaySite NameJob No
Monday

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]Date[/TD]
[TD="align: center"]Start Time[/TD]
[TD="align: center"]Break[/TD]
[TD="align: center"]Finish Time[/TD]
[TD="align: center"]Hours[/TD]
[TD="align: center"]Normal[/TD]
[TD="align: center"]1.5 Time[/TD]
[TD="align: center"]2.0 Time[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]01-Jan-19[/TD]
[TD="align: center"]7:00[/TD]
[TD="align: center"][/TD]
[TD="align: center"]21:00[/TD]
[TD="align: center"]14[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]01-Jan-19[/TD]
[TD="align: center"]9:00[/TD]
[TD="align: center"][/TD]
[TD="align: center"]12:00[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]01-Jan-19[/TD]
[TD="align: center"]12:00[/TD]
[TD="align: center"]1:00[/TD]
[TD="align: center"]16:00[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]2.00[/TD]
[TD="align: center"]21.33[/TD]

[TD="align: center"]5[/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"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]02-Jan-19[/TD]
[TD="align: right"]9:00[/TD]
[TD="align: right"][/TD]
[TD="align: center"]17:45[/TD]
[TD="align: center"]8.75[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]1.13[/TD]
[TD="align: center"]0.00[/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: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]03-Jan-19[/TD]
[TD="align: center"]9:00[/TD]
[TD="align: center"]1:00[/TD]
[TD="align: center"]20:00[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]03-Jan-19[/TD]
[TD="align: center"]8:00[/TD]
[TD="align: center"]2:00[/TD]
[TD="align: center"]17:00[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]2.00[/TD]
[TD="align: center"]15.33[/TD]

[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]04-Jan-19[/TD]
[TD="align: center"]9:00[/TD]
[TD="align: center"]1:30[/TD]
[TD="align: center"]17:30[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]13[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]05-Jan-19[/TD]
[TD="align: center"]9:00[/TD]
[TD="align: center"][/TD]
[TD="align: center"]17:00[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

</tbody>
Nunya6

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]H2[/TH]
[TD="align: left"]=IF(E2<>"",(G2-E2-F2)*24,"")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]I2[/TH]
[TD="align: left"]=IF(AND(D2<>D3,D2<>""),MIN(SUMIFS(H:H,D:D,D2),8),"")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]J2[/TH]
[TD="align: left"]=IF(AND(ISNUMBER(I2),SUMIFS(H:H,D:D,D2)>8),MIN(SUMIFS(H:H,D:D,D2)-8,1.33333)*1.5,"")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]K2
[/TH]
[TD="align: left"]=IF(ISNUMBER(J2),MAX(0,(SUMIFS(H:H,D:D,D2)-9.333333)*2),"")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Re: IF formula help

Ok so another spanner has been thrown in the works.

When the guys do night shift 6pm-7am it returns a negative value and the formulas dont work

What I am trying to do is use one row starting with row 7 as a night shift only column I know you can use a custom format
<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
#,###;#,### which turns it into a positive value or you can go =H7*-1 to turn it into a positive but getting it to work in with the formulas is driving me crazy I cannot work it out
 
Upvote 0
I can just leave it and manually convert it but would be nicer if there was a way to turn it into a positive and still work with the formulas

it will only be one row per day
 
Upvote 0
[TABLE="class: grid, width: 1000"]
<tbody>[TR]
[TD]Day[/TD]
[TD]Site[/TD]
[TD]Job[/TD]
[TD]Date[/TD]
[TD]Start Time[/TD]
[TD]break[/TD]
[TD]finish time[/TD]
[TD]hours[/TD]
[TD]normal[/TD]
[TD]1.5 time[/TD]
[TD]2.0 time[/TD]
[/TR]
[TR]
[TD]Monday[/TD]
[TD][/TD]
[TD]X[/TD]
[TD]01/01/19
[/TD]
[TD]630am[/TD]
[TD][/TD]
[TD]7:30am[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]Y[/TD]
[TD]01/01/19[/TD]
[TD]7:30am[/TD]
[TD]:30[/TD]
[TD]4pm[/TD]
[TD]8[/TD]
[TD]7[/TD]
[TD]1
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]01/01/19[/TD]
[TD]4pm[/TD]
[TD][/TD]
[TD]18:00[/TD]
[TD]2[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]01/01/19[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]01/01/19[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Night Shift[/TD]
[TD][/TD]
[TD]Z[/TD]
[TD]01/01/19[/TD]
[TD]6pm[/TD]
[TD][/TD]
[TD]3:30am[/TD]
[TD]-14.50[/TD]
[TD][/TD]
[TD][/TD]
[TD]14.50[/TD]
[/TR]
[TR]
[TD]daily total[/TD]
[TD][/TD]
[TD][/TD]
[TD]01/01/19[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]8[/TD]
[TD]2[/TD]
[TD]15.50[/TD]
[/TR]
</tbody>[/TABLE]

Ok so currently everything works but one of the guys has raised issues which I now have to fix and need help please. Currently you out the dates in and hours etc and it comes up as a daily total which I still need to happen.

However in the red is what I also need to happen so I need the hours to show per job X Y so forth and then the daily totals down the bottom.

I also need to get the night shift row to convert to a positive figure and sit in double time field.

Is this douable??? Remebering the normal hours have to cap at 8, 1.5 time has to cap at 2 and the rest goes into double time with no multiplications now just hours as they are.

Please and thanks
 
Upvote 0
Nunya,

I'm on vacation for a few weeks, over 4,000 miles from home, so won't be able to help.

Your latest sample data has incorrect format times entered and it looks like you've changed the trigger to job rather than date so I'm not sure what to do if the date changes, or a job appears across days, or if the job needs the OT calculation or if it's the staff only. You could change the Hours calculation to account for going past midnight but it will be against the start day and not the second day.

Code:
=IF(E2="","",IF(G2 < E2,((1-E2)+G2-F2)*24,(G2-E2-F2)*24))
<e2,((1-e2)+g2-f2)*24,(g2-e2-f2)*24))[ code]


If I fix the time format of your data then on my version of the sheet it is:

ABCDEFGHIJK
DaySiteJobDateStart Timebreakfinish timehoursnormal1.5 time2.0 time
MondayX
Y
Night ShiftZ
daily total

<tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"][/TD]

[TD="align: right"]1/1/2019[/TD]
[TD="align: right"]6:30[/TD]
[TD="align: right"][/TD]
[TD="align: right"]7:30[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]1/1/2019[/TD]
[TD="align: right"]7:30[/TD]
[TD="align: right"]0:30[/TD]
[TD="align: right"]16:00[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/1/2019[/TD]
[TD="align: right"]16:00[/TD]
[TD="align: right"][/TD]
[TD="align: right"]18:00[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/1/2019[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/1/2019[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]7[/TD]

[TD="align: right"][/TD]

[TD="align: right"]1/1/2019[/TD]
[TD="align: right"]18:00[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3:30[/TD]
[TD="align: center"]9.5[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]8[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/1/2019[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]2.00[/TD]
[TD="align: center"]22.33[/TD]

</tbody>
Nunya8

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]H2[/TH]
[TD="align: left"]=IF(<font color="Blue">E2="","",IF(<font color="Red">G2<e2,((1-E2)+G2-F2</e2,()*24,(G2-E2-F2)*24))[/TD]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]I2[/TH]
[TD="align: left"]=IF(AND(D2<>D3,D2<>""),MIN(SUMIFS(H:H,D:D,D2),8),"")[/TD]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]J2[/TH]
[TD="align: left"]=IF(AND(ISNUMBER(I2),SUMIFS(H:H,D:D,D2)>8),MIN(SUMIFS(H:H,D:D,D2)-8,1.33333)*1.5,"")[/TD]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]K2[/TH]
[TD="align: left"]=IF(ISNUMBER(J2),MAX(0,(SUMIFS(H:H,D:D,D2)-9.333333)*2),"")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]


</e2,((1-e2)+g2-f2)*24,(g2-e2-f2)*24))[>
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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