Error in a If Round function.

CrazyDave

New Member
Joined
Jan 15, 2014
Messages
38
Office Version
  1. 2013
Platform
  1. Windows
I have a spreadsheet, which, in part, records my start and finish times. From this, I work out the length of each shift. I have a formula to round the length of each shift to the nearest 15 minutes. That works. My issue is that the same formula also looks to see if the length of the shift is less than 2 hours.... if it is less than 2 hours, the formula is supposed to return a shift length of 2 hours... it doesn't... it rounds it out to the nearest 15 minutes... Quite frustrating really....
AL is the column for my Start Time.
AN is the column for my Finish Time.
AQ is the column where the formula gets entered. This is the formula - =IF(AN2="","",IF(AN2-AL2>"2:00","2:00",ROUND((AN2-AL2)*96,0)/96))

4:15 to 6:15 calculates as 2:00
3:15 to 5:54 calculates as 2:45

But... 4:15 to 6:04 calculates to 1:45, when it should be 2:00.

I've even tried to reverse this by switching the '>' to '<' and putting the result of "2:00" to the end of the formula, and I get the same results....

Any help will be much appreciated.
Capture.JPG
 

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.
Give this a try:
=IF(AND(ISNUMBER(AN2),ISNUMBER(AL2)),MAX("2:00",ROUND((AN2-AL2)*96,0)/96),"")
 
Upvote 0
Solution
Many thanks KRice!!!
I think I'd need to do some research as to how this works...
 
Upvote 0
Glad to help. Briefly, the formula confirms that the two time cells contain numbers, and if either is blank, then a blank is returned. If both numbers (times) are present, then the difference is taken and rounded to the nearest 15 minutes using your original formula. If the difference in times is less than 2 hours, you still want 2 hours returned. A convenient way to achieve that outcome is to use the MAX function, setting the lowest value to 2:00 and the other argument to the true time difference rounded to the nearest 15 minutes. So if the real time difference is greater than 2:00, you'll get that result; and if it is less than 2:00, the MAX function will ensure that 2:00 is still returned as the answer. Post back if you run into any difficulties.
 
Upvote 0

Forum statistics

Threads
1,214,615
Messages
6,120,538
Members
448,970
Latest member
kennimack

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