Index Match Across Multiple String Criteria

St Jimmy

New Member
Joined
Oct 29, 2015
Messages
36
I'm sure there is an easy solution, but my brain (nor google it seems) can find it...

I'm trying to match two string criteria in an index match formula and I dont want to use an array.
ABC
1VialIDBatch
2V001Z0011
3V002Z0021
4V003Z0012
5V004Z0031
6V005Z0013
7V006Z0032
8V007Z0041

<tbody>
</tbody>

I'd like to enter the ID and the Batch and get the Vial returned.
I'd like something like this: Index(A2:A8,Match(and("Z003",2),and(B2:B8,C2:C8),0))
And have V006 returned.

I'd prefer no arrays, is this possible? Any help is greatly appreciated!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Excel 2010
ABCDEFGHI
1ABCIDZ003
21VialIDBatchBatch2
32V001Z0011VialV006
43V002Z0021
54V003Z0012
65V004Z0031
76V005Z0013
87V006Z0032
98V007Z0041
10
11

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Array Formulas
CellFormula
H3{=INDEX(B3:B9,MATCH(H1&H2,C3:C9&D3:D9,0))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0
You could do it with a helper column. In Column D, CONCATENATE or use & to join the two entries to give Z0011, Z0021, Z0012 etc.
Code:
=B2&C2
or 
=CONCATENATE(B2,C2)
Then you can use:
Code:
[FONT=Verdana][FONT=Verdana]=INDEX(A2:A8,MATCH(G1&G2,D2:D8,0))[/FONT][/FONT]
(my lookup ID and batch are in G1 and G2).

I think that without the helper column, you will need an array formula to concatenate the values in the two arrays:
Code:
[FONT=Verdana]=INDEX(A2:A8,MATCH(G1&G2,B2:B8&C2:C8))[/FONT]
then enter with Ctrl-Shift-Enter. Excel will add curly braces around the entire formula.
 
Upvote 0
If you have Excel ver. 2010 or later you could use this formula. This is still an array formula, but you don't have to use CTRL-SHIFT-ENTER. Just ENTER.
Excel Workbook
ABCDEF
1VialIDBatchIDZ003
2V001Z0011Batch2
3V002Z0021
4V003Z0012VialV006
5V004Z0031
6V005Z0013
7V006Z0032
8V007Z0041
Sheet
 
Upvote 0
Thank you AhoyNC, and go Canes!

I'm going to bump the stakes on this post (hijacking my own thread in the process).
What I'm trying to do is use this code in a VBA macro in place of my quicksort function. I've found that the application.worksheetfunction index(match works about 5x as fast as my quicksort function (ouch, my pride) and I'm trying to replace all my calls to my quicksort with the application.worksheetfunction type (and time everything to make sure it is really saving me time).

That said, I tried to convert your formula to VBA code and it keeps throwing a type-mismatch error.

BatchBioInfo is a variant 2D array, ID is a string, i is an int, were in a nested for loop j in i.

Code:
BatchBioInfo (i,j) = Application.WorksheetFunction.Index(Sheets("VIALDB").Range("$A$2:$A$8"), Application.WorksheetFunction.Aggregate(15,6, (Sheets("VIALDB").Range("$A$2:$A$8").Row - Sheets("VIALDB").Range("$A$2").Row + 1) / ((Sheets("VIALDB").Range("$B$2:$B$8").Value2 = ID) * (Sheets("VIALDB").Range("$C$2:$C$8").Value2 = i)), 1))

Any thoughts why this code wont work in VBA?
Thank you!!!!!
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,276
Members
449,075
Latest member
staticfluids

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