INDEX & MATCH with multiple criteria

mwelshman

New Member
Joined
Jan 18, 2018
Messages
3
Hi,

I have an INDEX & MATCH problem I'm having trouble solving. The first part works ok, shown below; return a value from B4:B49 where J4 is greater than or equal to C4:C49, J4 is less that or equal to D4:D49, J3 is greater than or equal to E4:E49, J3 is less that or equal to G4:G49.

I'd like to add in another criteria where J3 is closest to F3:F49. It doesn't matter whether it's greater or less than, just that it's the closest.

=INDEX(B4:B49,MATCH(1,(J4>=C4:C49)*(J4<=D4:D49)*(J3>=E4:E49)*(J3<=G4:G49),0))

Can anyone help me which formula to use/add into my existing formula?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try this:

=INDEX($B$4:$B$49,MATCH(AGGREGATE(15,6,ABS($J$3-(INDEX(((J4>=C4:C49)*(J4<=D4:D49)*(J3>=E4:E49)*(J3<=G4:G49))*$F$4:$F$49,))),1),ABS($J$3-$F$4:$F$49),0))

( It is an array formula, so enter it with; Ctrl. + Shft. + Enter )
 
Upvote 0
@ Chrisdontm

Do we really need AGGREGATE and inner INDEX as the latter cannot circumvent control+shift+enter?

More importantly, the match range you have is underspecified which can lead to a wrong outcome. The following does have the correct match-rage for the MATCH bit:

=INDEX(B4:B49,MATCH(MIN(ABS(J3-IF(J4>=C4:C49,IF(J4<=D4:D49,IF(J3>=E4:E49,IF(J3<=G4:G49,F4:F49)))))),ABS(J3-IF(J4>=C4:C49,IF(J4<=D4:D49,IF(J3>=E4:E49,IF(J3<=G4:G49,F4:F49))))),0))

which must be confirmed with control+shift+enter, not just enter.
 
Upvote 0
This is excellent and it almost works. Thanks Aladin Akyurek. However I need it to error or not return a result if none of the criteria are met. Currently this formula returns the result in the first row if my original criteria below aren't met. Is this able to built into the IF statement somewhere?

(J4>=C4:C49)*(J4<=D4:D49)*(J3>=E4:E49)*(J3<=G4:G49)
 
Upvote 0
This is excellent and it almost works. Thanks Aladin Akyurek. However I need it to error or not return a result if none of the criteria are met. Currently this formula returns the result in the first row if my original criteria below aren't met. Is this able to built into the IF statement somewhere?

(J4>=C4:C49)*(J4<=D4:D49)*(J3>=E4:E49)*(J3<=G4:G49)

Control+shift+enter, not just enter:

=IF(COUNTIFS(C4:C49,"<="&J4,D4:D49,">="&J4,E4:E49,"<="&J3,G4:G49,">="&J3),INDEX(B4:B49,MATCH(MIN(ABS(J3-IF((J4>=C4:C49)*(J4<=D4:D49)*(J3>=E4:E49)*(J3<=G4:G49),F4:F49))),ABS(J3-IF((J4>=C4:C49)*(J4<=D4:D49)*(J3>=E4:E49)*(J3<=G4:G49),F4:F49)),0)),NA())

If any of the conditions are not met, we get #N/A. If you want something different, just replace NA().
 
Upvote 0

Forum statistics

Threads
1,215,334
Messages
6,124,325
Members
449,154
Latest member
pollardxlsm

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