MAX Value based on Time range- not working correctly

InstructorAmberA

New Member
Joined
Oct 15, 2018
Messages
7
row/columnCDE--->BD ---->BI
11StartEndTargetTimeHourTarget
123:00 AM6:00 AM212:00 AM1
131:00 AM6:00 AM41:00 AM4
144:00 AM6:00 AM22:00 AM3
154:00 AM7:00 AM33:00 AM2
161:00 AM5:00 AM44:00 AM2
179:00 PM12:00 AM55:00 AM2
|6:00 AM3
|keeps going hour by hour
3511:00 PM5

<tbody>
</tbody>




























Goal: Make the Red cells calculate themselves. Max TARGET (BI) based On block of time shown in C to D .

Range BD12-BD35 (TimeHour)= Hours of the day (1 cell per hour)
BI12-BI35 (Target) are the Targets for those hours individually. Columns BE-BH have other data not relevant to this formula.

E12 -E17 is filled out manually. It is the highest (Target) number in the range of time shown. Example 3am, 4am, 5am hours are target 2, 2, 2, so give me E12=2
Row 16 - 1AM to 5AM, 1AM=4, 2AM = 3, 3AM=3, 4AM=2 so highest target is 4, give me 4.

{=MAX(IF($BD$12:$BD$40>=C12,IF($BD$12:$BD$40=D12,$BI$12:$BI$40)))} is giving me 0 in every cell. I did use CSE to enter it and it provided the { }. I typed them here for your reference.

Bad Result = 0 for everything. I originally had the table BD-BI on another worksheet called Sheet5 in this formula. I copied it over to the main page to see if it would change, but still zeros.


=MAX(IF((Sheet5!$A$4:$A$27<=D12)*(Sheet5!$A$4:$A$27>=C12),Sheet5!$F$4:$F$27,""))


https://www.mrexcel.com/forum/excel-questions/509384-find-max-min-value-based-time-criteria.html

I found this article above and was trying to use it to create/fix but I am still missing something. Any help would be appreciated.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
It would still give an error with any window ending at midnight i.e. 12AM. So for such windows, all such 12 AM in column D may be replaced with 11:59 PM.
 
Last edited:
Upvote 0
Thank you KolGuyXcel That worked. :)
Just for future if anyone is seeing this post - I had another problem that I just realized but am not sure how I caused.
Each of the time columns was manually typed. And each only shows Hour, minutes AM/PM like above.

After further hunting for why it wasn't working I found in the formula bar - One (Column BD) was showing 3:00:00 while the others (C and D)were showing 3:00 Without the seconds. Even with the change in formula, it would not work until the seconds got manually added to BD
 
Upvote 0
Technically, ending at 12am only needs to count the targets of the hour before (11pm).
Each of these can really disregard the end time column.... is there a way to make it look at Start hour to End hour minus 59 minutes ?

Line 14 for example -
4am to 6am is really getting the target for the 4am and 5am hours. 6am itself is irrelevant, just that it ends there and won't go further.
Technically the time should be 4am to 5:59am but I will have issue with sending out schedules if I change them to show that. Can the formula assume it instead?
 
Upvote 0

Forum statistics

Threads
1,214,988
Messages
6,122,620
Members
449,092
Latest member
amyap

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