Index and Match between Two Dates

matthewlouis

Active Member
Joined
Mar 28, 2014
Messages
374
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hey EXCEL experts, I need a formula for an index and match that looks for a number that is below another cell number. Attached is an image with more explanation. The key is to keep the index / match between the two dates on the sheet in each column.

Thanks in advance!
 
pj, whatever you can offer would be much appreciated. This one has me stumped!
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Are you able to share the spreadsheet, say via Dropbox?
 
Upvote 0
Not a member . . . did the trial a few years ago and haven't joined. Don't need it very much. Any other way I can get you the file?
 
Upvote 0
I think Fluff’s answered the question that it’d have to be a cloud share. I’ll see what I can do with what I’ve got - might take a while!
 
Upvote 0
Well I think this works, it seems to work for me!

=IFERROR(INDEX($F$16:$F$10000,SMALL(IF(($B$16:$B$10000>=I$2)*($B$16:$B$10000<=I$3)*($F$16:$F$10000<I$4),ROW($F$16:$F$10000)-ROW($F$15)),COUNT(IF(($B$16:$B$10000>=I$2)*($B$16:$B$10000<=I$3)*($F$16:$F$10000<I$4),ROW($F$16:$F$10000)-ROW($F$15))))),"")

entered with CTRL-SHFT-ENTER, (make sure it has curly braces around it)

It looks horrendouse, but:

The IFERROR simply puts a blank if no value is found - the inner code returns a #NUM error.
The inner code returns the row number of the value we want and INDEX($F$16:$F$10000 is the list from which we want the number.

This section: ($B$16:$B$10000>=I$2) * ($B$16:$B$10000<=I$3) * ($F$16:$F$10000<I$4) tests the dates against the earliest date, then the latest date, and then tests the values against your lower limit. If you've moved the upper date change I$3 as necessary.

The COUNT formula is used to find how many items have been returned as it is the last one in the list that we want. We could replace this whole section with 1 if the dates ran from oldest to newest down the page!

I'm indebted to www.exceltip.com for the idea of how to do this: 'How to Find the nth Occurrence'

HTH
 
Upvote 0
Awesome!! I’ll plug it in morning and get back. You’re awesome pj, thank you!!
 
Upvote 0
You, sir, are amazing! Works perfect! Thanks so much!

If I can ask . . . if I wanted to see the FIRST close over a HIGH instead of a low, would I reverse the > signs as shown below (different numbers in cell I3, of course)

=IFERROR(INDEX($F$16:$F$10000,LARGE(IF(($B$16:$B$10000>=I$2)*($B$16:$B$10000<=I$3)*($F$16:$F$10000>I$4),ROW($F$16:$F$10000)-ROW($F$15)),COUNT(IF(($B$16:$B$10000>=I$2)*($B$16:$B$10000<=I$3)*($F$16:$F$10000>I$4),ROW($F$16:$F$10000)-ROW($F$16))))),"")

This is also a way (bullish) for me to track the trend of the market. Would that be the formula?

Again, I cannot thank you enough for the manual work you have saved me!
 
Upvote 0
I have the spreadsheet ready to attach -- how do you attach it? I just see mage and URL (?)
Here's how

Also, it would help if you update your user profile to show which version of excel you use so that people helping you know what features and functions you have. To do this, click your user name in the top right corner of the screen, then go to 'Account Details', then scroll down and check the correct boxes, remember to scroll to the bottom and save any changes before leaving the page.

I've tried to simplify the formula that @pjmorris suggested, this is not tested and will not work with anything older than excel 2010. This one will not need to be array confirmed.

=IFERROR(INDEX($F:$F,AGGREGATE(15,6,ROW($F$16:$F$10000)/($B$16:$B$10000>=I$2)*($B$16:$B$10000<=I$3)*($F$16:$F$10000<I$4),COUNTIFS($B$16:$B$10000,">="&I$2,$B$16:$B$10000,"<="&I$3,$F$16:$F$10000,"<"&I$4))),"")
 
Last edited:
Upvote 0
Matthew,

I like your thinking, and you gave me an idea to simplify both formulas. To get the first under the figure use:

=IFERROR(INDEX($F$16:$F$10000,LARGE(IF(($B$16:$B$10000>=I$2)*($B$16:$B$10000<=I$3)*($F$16:$F$10000<I$4),ROW($F$16:$F$10000)-ROW($F$15)),1)),"")

and for the first over:

=IFERROR(INDEX($F$16:$F$10000,LARGE(IF(($B$16:$B$10000>=I$2)*($B$16:$B$10000<=I$3)*($F$16:$F$10000>I$4),ROW($F$16:$F$10000)-ROW($F$15)),1)),"")

Both array entered. I hadn't thought to use LARGE until you did, but it affects which of the rows is returned rather than being a function of the comparison - by using that rather than SMALL i could get rid of the COUNT section.

HTH
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

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