How To Use Index and Match
How To Use Index and Match
INDEX and MATCH is the most popular tool in Excel for performing more advanced
lookups. This is because INDEX and MATCH is incredibly flexible – you can do
horizontal and vertical lookups, 2-way lookups, left lookups, case-sensitive lookups, and
even lookups based on multiple criteria. If you want to improve your Excel skills, INDEX
and MATCH should be on your list.
This article explains in simple terms how to use INDEX and MATCH together to perform
lookups. It takes a step-by-step approach, first explaining INDEX, then MATCH, then
showing you how to combine the two functions together to create a dynamic two-way
lookup. There are more advanced examples further down the page.
At this point, you may be thinking "So what? How often do you actually know the
position of something in a spreadsheet?"
Exactly right. We need a way to locate the position of things we're looking for.
From the examples above, we know MATCH works fine with both horizontal and
vertical arrays. That means we can easily find the position of a given month with
MATCH. For example, this formula return the position of March, which is 3:
=MATCH("Mar",C2:E2,0) // returns 3
But of course we don't want to hardcode any values, so let's update the worksheet to
allow the input of a month name, and use MATCH to find the column number we need.
The screen below shows the result:
A fully dynamic, two-way lookup with INDEX and MATCH.
=INDEX(C3:E11,MATCH(H2,B3:B11,0),MATCH(H3,C2:E2,0))
The first MATCH formula returns 5 to INDEX as the row number, the second MATCH
formula returns 3 to INDEX as the column number. Once MATCH runs, the formula
simplifies to:
=INDEX(C3:E11,5,3)
and INDEX correctly returns $10,525, the sales number for Frantz in March.
Note: you could use Data Validation to create dropdown menus to select salesperson and
month.
Video: How to do a two-way lookup with INDEX and MATCH
Video: How to debug a formula with F9 (to see MATCH return values)
Left lookup
One of the key advantages of INDEX and MATCH over the VLOOKUP function is the
ability to perform a "left lookup". Simply put, this just means a lookup where the ID
column is to the right of the values you want to retrieve, as seen in the example below:
Read a detailed explanation here.
Case-sensitive lookup
By itself, the MATCH function is not case-sensitive. However, you use the EXACT
function with INDEX and MATCH to perform a lookup that respects upper and lower
case, as shown below:
Read a detailed explanation here.
Note: this is an array formula and must be entered with control + shift + enter, except
in Excel 365.
Closest match
Another example that shows off the flexibility of INDEX and MATCH is the problem of
finding the closest match. In the example below, we use the MIN function together with
the ABS function to create a lookup value and a lookup array inside the MATCH
function. Essentially, we use MATCH to find the smallest difference. Then we use
INDEX to retrieve the associated trip from column B.
Read a detailed explanation here.
Note: this is an array formula and must be entered with control + shift + enter, except
in Excel 365.
Multiple criteria lookup
One of the trickiest problems in Excel is a lookup based on multiple criteria. In other
words, a lookup that matches on more than one column at the same time. In the example
below, we are using INDEX and MATCH and boolean logic to match on 3 columns:
Item, Color, and Size:
Read a detailed explanation here.
Note: this is an array formula and must be entered with control + shift + enter, except
in Excel 365.
More examples of INDEX + MATCH
Here are some more basic examples of INDEX and MATCH in action, each with a
detailed explanation:
Author