multiple criteria match

maxvo

New Member
Joined
Nov 5, 2017
Messages
2
hi,

I am trying to do an index match for 2 criteria. Lets say i have to return a random number from column C. Matching criteria 1 is DEF and matching criteria 2 is 01/11/2021 (I'd like to match the closest date). So ideally I would return Random(6).

A B C
ABC 01/01/2020 random(1)
ABC 01/01/2021 random(2)
ABC 01/01/2022 random(3)
DEF 01/01/2020 random(4)
DEF 01/01/2021 random(5)
DEF 01/01/2022 random(6)

I'm struggling to merge the 2 criteria into a single formula. I thought along the lines of sumproduct or Match(criteria1&2,range1&2) but struggling to formulate this.

Help would incredibly appreciated.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Unknown
ABC
1NameDateRandom
2ABC01/01/2020random(1)
3ABC01/01/2021random(2)
4ABC01/01/2022random(3)
5DEF01/01/2020random(4)
6DEF01/01/2021random(5)
7DEF01/01/2022random(6)
8
9Matching Criteria 1Matching Criteria 2Result
10DEF01/11/2021random(6)
Sheet6
Cell Formulas
RangeFormula
C10{=INDEX($C$2:$C$7,MATCH(MIN(IF(A10=$A$2:$A$7,ABS($B$2:$B$7-B10))),IF(A10=$A$2:$A$7,ABS($B$2:$B$7-B10)),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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