Find max and min value based on time criteria

dorian_810

New Member
Joined
Nov 16, 2010
Messages
2
hello, im trying to find the max and min of
a range between a specific time period and
have this repeat at this time period giving the max/min
for each individual period. EX: column A is Date,
column B is Time , column C is open price. D is High price,
E is Low price, F is Close price. I want to find the max/min or high/low of price
between 9:00am and 12:00pm on 7/12/2010 and have the max/min price shown
in column J:1/K:1. Then have this repeat for next day 7/13/2010 and results in J:2/K:2
Thanks for any help you can provide.

note:
A date B time C open D high E low F close G volume
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the Board!

Try using something like this for your MAX:

Code:
=MAX(IF(A2:A10 = DATEVALUE("7/12/2010"), IF(B2:B10>TIMEVALUE("9:00:00 AM"), IF(B2:B10<=TIMEVALUE("12:00:00 PM"), D2:D10, 0), 0),0))

and something like this for your MIN:

Code:
=MIN(IF(A2:A10 = DATEVALUE("7/12/2010"), IF(B2:B10>TIMEVALUE("9:00:00 AM"), IF(B2:B10<=TIMEVALUE("12:00:00 PM"), E2:E10))))

Both formulas are array formulas and must be entered with CTRL+SHFT+ENTER instead of just ENTER. If you do it correctly, the formula bar should automatically insert/display curly braces around the formula for you {}. Do not type them in, they appear when the CSE is pressed.

Just a side note, you may wish to have your reference dates (7/12/2010, 7/13/2010, etc.) in cells next to the formulas. Then you could easily refer to them in the formula instead of the hard-coded dates. This would allow you to update them easier. Also, referencing the times in cells could also make it easier to update if you ever need to change the times in several cells.
 
Last edited:
Upvote 0
Hi Nogslaw.

Thanks for the help. I've been playing
around with the code you provided and it
seems to work well.

The only problem is i need to find a way to
have it repeat for every day.
EX: i need to pull the max/min for monday at
9 am to 12pm and post these values in a cell (d1).
Then tuesday find max/min at 9am to 12pm and post
these values in d2. And the next day and so on until
the end of the data list is reached.

I hope this makes sense. Agian thanks for the help.
 
Upvote 0
The easiest way is going to be to place the date in an adjacent cell, then reference that date in the formula.

For example, in cell L1, place the date 7/12/2010. Then use this modified formula for your MAX in J1:

Code:
=MAX(IF($A$2:$A$10 = L1, IF($B$2:$B$10>TIMEVALUE("9:00:00 AM"), IF($B$2:$B$10<=TIMEVALUE("12:00:00 PM"), $D$2:$D$10, 0), 0),0))

and this one for your min in K1:

Code:
=MIN(IF($A$2:$A$10 = L1, IF($B$2:$B$10>TIMEVALUE("9:00:00 AM"), IF($B$2:$B$10<=TIMEVALUE("12:00:00 PM"), $E$2:$E$10))))

You can copy the code down the column and when you add each day's date into the adjacent cell in column L it will update for that date.
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,025
Members
452,542
Latest member
Bricklin

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