Look up in any direction with INDEX and MATCH
Lookups in any direction8 minPremium
Builds on Look up a value with VLOOKUP.
The HR team at an engineering firm in Calgary keeps its staff list with names in the first column and employee IDs further right. Payroll sends only IDs. VLOOKUP can't return a column to the left of the one it searches, and some colleagues still run Excel 2016, which has no XLOOKUP.
How it works
INDEX and MATCH split a lookup into two questions: where is the value, and what sits beside it.
| Row | A | B | C |
|---|---|---|---|
| 1 | Part | What it does | Example |
| 2 | MATCH( | returns the position of a value in a column: 1 for the first cell, 2 for the second | MATCH( is 5 |
| 3 | INDEX( | returns the value at that position of another column | INDEX( is the value in A6 |
Put MATCH inside INDEX and you have a lookup: INDEX(. Picture a finger running down the part numbers and counting rows until it reaches the one you want, then your eyes moving along that row to the column you need. The two columns are separate ranges, so the answer can sit on either side, and a column inserted between them changes nothing.
Positions line up only when both ranges start on the same row and have the same number of rows. The 0 asks MATCH for an exact match; without it, MATCH assumes the list is sorted.
Example
A parts warehouse lists bin locations in A2:A8, part names in B2:B8 and part numbers in C2:C8. The part number to find is in B10.
=INDEX(A2:A8,MATCH(B10,C2:C8,0))- Step 1: MATCH takes the part number in
B10, P-58120. - Step 2: It looks down
C2:C8and finds it 5th, in C6. - Step 3: INDEX takes the 5th cell of
A2:A8, A6, on the same row. - Step 4: B11 shows that bin, B-03-2.
Common mistakes
=INDEX(leaves out the 0. MATCH then assumes the part numbers are sorted and can stop on another part's row, with no error.A2:A8, MATCH( B10, C2:C8)) =INDEX(starts the two ranges on different rows. MATCH counts from C2 and INDEX from A1, so you get the bin one row up.A1:A8, MATCH( B10, C2:C8, 0)) =MATCH(on its own shows 5, the position. Put it inside INDEX to get the bin.B10, C2:C8, 0)
In short
- MATCH answers where:
MATCH(returns a position.what, where, 0) - INDEX answers what:
INDEX(returns what sits there.range, position) - Together,
INDEX(looks up in any direction, in any version.return column, MATCH( what, search column, 0)) - Start both ranges on the same row, and end MATCH with 0.
Practice
Premium4 exercises: 3 formulas and 1 selection.
Practice is part of Premium
Every lesson is free to read, and you can practice the free lessons without an account. This lesson's exercises are part of Premium, which you add to a free account.
Have one? Sign in