# IF formula

#### Nunya1

##### New Member
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)

TIA

#### Nunya1

##### New Member
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)

### Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

##### Well-known Member
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
1DaySite NameJob NoDateStart TimeBreakFinish TimeHoursNormal1.5 Time2.0 Time
2Monday01-Jan-197:0021:0014
301-Jan-199:0012:003
401-Jan-1912:001:0016:00382.0021.33
5
602-Jan-199:0017:458.7581.130.00
7
803-Jan-199:001:0020:0010
903-Jan-198:002:0017:00782.0015.33
10
1104-Jan-199:001:3017:3077
12
1305-Jan-199:0017:0088

</tbody>
Nunya6

Worksheet Formulas
CellFormula
H2=IF(E2<>"",(G2-E2-F2)*24,"")
I2=IF(AND(D2<>D3,D2<>""),MIN(SUMIFS(H:H,D:D,D2),8),"")
J2=IF(AND(ISNUMBER(I2),SUMIFS(H:H,D:D,D2)>8),MIN(SUMIFS(H:H,D:D,D2)-8,1.33333)*1.5,"")
K2
=IF(ISNUMBER(J2),MAX(0,(SUMIFS(H:H,D:D,D2)-9.333333)*2),"")

</tbody>

<tbody>
</tbody>

#### Nunya1

##### New Member
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

#### Nunya1

##### New Member
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

#### Nunya1

##### New Member

 Day Site Job Date Start Time break finish time hours normal 1.5 time 2.0 time Monday X 01/01/19 630am 7:30am 1 1 Y 01/01/19 7:30am :30 4pm 8 7 1 01/01/19 4pm 18:00 2 1 1 01/01/19 01/01/19 Night Shift Z 01/01/19 6pm 3:30am -14.50 14.50 daily total 01/01/19 8 2 15.50

<tbody>
</tbody>

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.

##### Well-known Member
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
1DaySiteJobDateStart Timebreakfinish timehoursnormal1.5 time2.0 time
2MondayX1/1/20196:307:301
3Y1/1/20197:300:3016:008
41/1/201916:0018:002
51/1/2019
61/1/2019
7Night ShiftZ1/1/201918:003:309.5
8daily total1/1/201982.0022.33

<tbody>
</tbody>
Nunya8

Worksheet Formulas
CellFormula
H2=IF(<font color="Blue">E2="","",IF(<font color="Red">G2<e2,((1-E2)+G2-F2</e2,()*24,(G2-E2-F2)*24))
I2=IF(AND(D2<>D3,D2<>""),MIN(SUMIFS(H:H,D:D,D2),8),"")
J2=IF(AND(ISNUMBER(I2),SUMIFS(H:H,D:D,D2)>8),MIN(SUMIFS(H:H,D:D,D2)-8,1.33333)*1.5,"")
K2=IF(ISNUMBER(J2),MAX(0,(SUMIFS(H:H,D:D,D2)-9.333333)*2),"")

<tbody>
</tbody>

<tbody>
</tbody>

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

Replies
2
Views
85
Replies
4
Views
75
Replies
8
Views
127
Replies
25
Views
390
Replies
9
Views
184

### Forum statistics

1,130,214
Messages
5,640,910
Members
417,178
Latest member
HelpMeExcelExperts

### 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.

### Which adblocker are you using?

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

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