Index/Match If

kparadise

Board Regular
Joined
Aug 13, 2015
Messages
186
Hello,

I am looking for a formula. I have one tab with raw data, multiple records, multiple duplicates, etc (tab named [raw]). I have another tab [Plan] where I need to insert my formulas. In my reference cell A1; I will enter a unique ID number. I want to use that value I entered in A1 and look it up in the [raw] tab; and return a value in column c of the [raw] tab.

This is a simple Index Match formula, which is not my issue. The additional piece of this formula is, I need to find the corresponding cell in the [raw] tab that STARTS with my unique ID, and ends with "-AH1" or "-BH1".

[PLAN]A
B
1
UniqueIdResults
2
abcdered
3
zzzzzblue

<tbody>
</tbody>

[RAW]A
B
C
1
UniqueIDColorSize
2
abcdeblueS
3
abcdeblueM
4
abcde-AH1redL
5
abcde-AH1redL
6
abcde-AH2greenL
7
abcde-AH2orangeM
8
zzzzz-BH1
blueM
9
zzzzzredS

<tbody>
</tbody>
 
Last edited:
I didn't notice the new requirement "-DD1"

Try this new version

Array formula in B2 copied down
=INDEX(RAW!B$2:B$9,MATCH(1,IF(LEFT(RAW!A$2:A$9,5)=A2,IF(ISNUMBER(MATCH(RIGHT(RAW!A$2:A$9,3),{"AH1";"BH1";"DH1"},0)),IF(RAW!C$2:C$9="L",1))),0))
confirmed with Ctrl+Shift+Enter, not just Enter

M.
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Could you please adjust the formula to SEARCH the beginning of the cell and the end of the cell, instead of looking for a number of characters?
 
Upvote 0
Post 5
But it will always START with the five letter uniqueID on the [PLAN] tab; and END with values after the dash.

As you said that always the first 5 characters correspond to the uniqueiID and the last three to AH1, BH1 etc, we have to use LEFT(text, 5) and RIGHT(text, 3)
Why and how to do it differently?

M.
 
Upvote 0
I am anticipating changes.

Can we a search; if the 5 letter unique ids appear in the raw data & if the 3 letter appears in the same raw data?

I know the 5 letter unique ID will be added; or possibly show in the middle of the cell. I also know eventually the "-AH1" will be "AH0001"... So I am just trying to make as dynamic as possible now that I have new information. I am sorry this changed...but can we do a SEARCH instead?
 
Upvote 0
You can replace LEFT(RAW!A$2:A$9,5)=A2 by ISNUMBER(SEARCH(A2,RAW!A$2:A$9))

As for the suffixes is more complicated, because the formula needs to know if you are looking for AH1, AH01, AH001 etc.
Maybe putting the suffix in a criteria cell and using the reference to this cell in the formula. I can only be sure if it works by testing in some examples ...

M.
 
Upvote 0
hmm.. see if this works

B2 copied down
=INDEX(RAW!B$2:B$9,MATCH(1,IF(ISNUMBER(SEARCH(A2,RAW!A$2:A$9)),IF(ISNUMBER(SEARCH("AH*1",RAW!A$2:A$9))+ISNUMBER(SEARCH("BH*1",RAW!A$2:A$9))+ISNUMBER(SEARCH("DH*1",RAW!A$2:A$9)),IF(RAW!C$2:C$9="L",1))),0))
Ctrl+Shift+Enter

M.
 
Upvote 0
This is working great!

It has been a long road; and I appreciate all the help and twists and turns! Thank you very much!
 
Upvote 0
New version - I think it's much better


A
B
C
D
E
1
UniqueId​
Results​
Suffixes​
Size​
2
abcde​
red​
AH*1​
L​
3
zzzzz​
red​
BH*1​
4
DH*1​

Criteria in columns D:E (observe the * in column D)

Formula in B2 copied down
=INDEX(RAW!B$2:B$9,MATCH(1,IF(ISNUMBER(SEARCH(A2,RAW!A$2:A$9)),IF(MMULT(--ISNUMBER(SEARCH(TRANSPOSE(D$2:D$4),RAW!A$2:A$9)),ROW(D$2:D$4)^0),IF(RAW!C$2:C$9=E$2,1))),0))
Ctrl+Shift+Enter

M.
 
Upvote 0

Forum statistics

Threads
1,215,268
Messages
6,123,975
Members
449,137
Latest member
yeti1016

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