Ifs not totaling properly - possibly a MOD

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hello All,

I was using an IF formula to accomplish my goals, however the statement seems to fail me when I run a time that passes midnight. Here is my current formula:
Code:
{=(SUM(IF(E$139:E$146<$B87,IF(F$139:F$146>$A87,IF(F$139:F$146<$B87,F$139:F$146,$B87)-IF(E$139:E$146>$A87,E$139:E$146,$A87))))*24)}

What this does:
It looks at A87& B87 for my criteria. In this case it is a time range: 9:00,10:00 Then it reviews the data in Rows 139:146.
Column E is the start time
Column F is the end time
If 9:00-10:00 falls in between the start and end time, then the count is increased by 1.

In this formula the total wouldn't be higher than 9 as there are only 9 rows being evaluated.
My problem occurs when an ending time is in the AM and excel thinks it is earlier and thus returns a negative value resulting in this formula not counting the row.

I've solved my other totaling issues with a MOD formula, but I am struggling to figure out how to successfully apply that here.

Any assistance would be greatly appreciated.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,215,386
Messages
6,124,628
Members
449,176
Latest member
Dazjlbb

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