Matching multiple value in excel using index and match

Viewed 24

I used index and match to identify the values of the table and matched it. However I am facing trouble when I try to get b and c, a is matched correctly

A. B C D.

1 a b c

2 fruit1 a
3 fruit0
4 fruit3
5 fruit5 a

E       F   

1 fruit1 a
2 fruit0 c
3 fruit3 b
4 fruit5 a

My formula is

=Iferror(if(index(($f$1:$f$4), match($A2,$e$1:$e$4,0),match(b$2,$f$1:$f$4,0)) = b$2,index(($f$1:$f$4), match($A2,$e$1:$e$4,0),match(b$2,$f$1:$f$4,0)), ""),"")

1 Answers

If your data table is in E1:F4, and you are trying to look up the fruit names that appear in column A starting at A2, and place the correct letter next to them in column B, then there's no need for the IF and the sequences of MATCHes.

All you need is this, pasted into cell B2 and copied down, is this:

=IFERROR(INDEX($F$1:$F$4,(MATCH(A2,$E$1:$E$4,0))),"")

An easier approach to this is just:

=VLOOKUP(A2,$E$1:$F$4,2,FALSE)

or to be safer:

=IFERROR(VLOOKUP(A2,$E$1:$F$4,2,FALSE),"")

And if you have access to O365 Excel and the newer XLOOKUP function, you can use the following examples. XLOOKUP incorporates the "not found" result so you don't have to do a separate IFERROR. Do do it on a cell-by-cell basis as you had before, put this in B2 and copy it down:

=XLOOKUP(A2,$E$1:$E$4,$F$1:$F$4,"",0)

If you want to go one step further, you can apply the XLOOKUP as an array or "spill" formula, you change the lookup_value to be the A1:A4 and it does the rest. Place this in B2 and it will fill B2 through B5:

=XLOOKUP(A2:A5,$E$1:$E$4,$F$1:$F$4,"",0)
Related