⇄Lookups7 min read ·

How to Use INDEX and MATCH in Excel

Learn INDEX and MATCH with real examples: exact matches, looking left, copying the formula down, two-way lookups and fixing #N/A and #REF! errors.

Quick answer

=INDEX(array, row_num, [column_num])

MATCH finds the position of a value in a list, and INDEX returns the item at that position from another column. Use =INDEX(return_range, MATCH(lookup_value, lookup_range, 0)), where 0 means exact match.

Arguments in [brackets] are optional.

On this page ⌄
  1. The INDEX and MATCH syntax
  2. A step-by-step INDEX MATCH example
  3. Always use 0 for an exact match
  4. Keep the ranges lined up
  5. Look up a value to the left
  6. Lock the ranges before copying down
  7. Two-way lookups with INDEX, MATCH and MATCH
  8. How to fix #N/A and #REF!
  9. Duplicates and upper or lower case
  10. INDEX MATCH vs XLOOKUP and VLOOKUP
  11. Key takeaways

INDEX and MATCH is the classic Excel lookup. MATCH finds where a value sits in a list, and INDEX returns what's at that position in another column. Nest one inside the other and you get a lookup that works in any direction:

=INDEX(return_range, MATCH(lookup_value, lookup_range, 0))

In words: find lookup_value in lookup_range, then return the item in the same position from return_range. The 0 means exact match.

The examples use this staff list, with headers in row 1 and data in rows 2 to 9:

A: IDB: NameC: Department
2E101Hannah LeeSales
3E102Omar HaddadFinance
4E103Grace KimMarketing
5E104Diego RuizSales
6E105Priya ShahIT
7E106Tom BeckerFinance
8E107Lena FischerIT
9E108Sam OkaforMarketing

The sheet also has Salary in column D and Start date in column E. They're left out of this table so the exercise below isn't spoiled, but the live sheet shows all five columns, and every range in this guide refers to it.

The INDEX and MATCH syntax

In the pattern above, lookup_range is MATCH's lookup_array and return_range is INDEX's array.

FunctionArgumentWhat it meansExample
MATCHlookup_valueThe value to find"Lena Fischer"
MATCHlookup_arrayThe single column or row to searchB2:B9
MATCHmatch_typeOptional. 0 = exact match. The default is 1, an approximate match0
INDEXarrayThe range holding the answerC2:C9
INDEXrow_numWhich position to return. MATCH goes here7
INDEXcolumn_numOptional. Which column, if array is several columns wide4

A step-by-step INDEX MATCH example

Which department is Lena Fischer in?

1. MATCH finds the position.

=MATCH("Lena Fischer", B2:B9, 0)→ 7

Lena is on worksheet row 8, yet MATCH returns 7, because it counts from the first cell of the range: B2 is position 1. MATCH gives a position inside the range, not a sheet row.

2. INDEX returns the item at that position.

=INDEX(C2:C9, 7)→ IT

3. Put MATCH inside INDEX, so Excel works out the 7 for you:

=INDEX(C2:C9, MATCH("Lena Fischer", B2:B9, 0))→ IT

Both ranges start in row 2, so position 7 means the same row in each. To return another column, change only the INDEX range:

=INDEX(D2:D9, MATCH("Lena Fischer", B2:B9, 0))→ $69,500

In a real workbook, point at a cell instead of typing the name: =INDEX(C2:C9, MATCH(K2, B2:B9, 0)). Press Enter as normal. These formulas don't need Ctrl+Shift+Enter in any version of Excel.

Your turn. This exercise asks for Priya Shah's salary. It accepts XLOOKUP, VLOOKUP or INDEX, and its model answer uses XLOOKUP, so try INDEX and MATCH instead: match the name in column B and return from the Salary column.

Try it yourself

A live spreadsheet. Type a formula and press Enter to check it.

staff-list.xlsx
fx
1IDNameDepartmentSalaryStart dateDepartmentBonus
2E101Hannah LeeSales$52,000.00Mar 15, 2021Sales10%Salary
3E102Omar HaddadFinance$61,000.00Jul 1, 2019Finance6%
4E103Grace KimMarketing$48,500.00Jan 9, 2023Marketing8%
5E104Diego RuizSales$57,500.00Nov 23, 2020IT7%
6E105Priya ShahIT$72,000.00May 14, 2018
7E106Tom BeckerFinance$66,000.00Sep 5, 2022
8E107Lena FischerIT$69,500.00Feb 19, 2024
9E108Sam OkaforMarketing$51,000.00Aug 30, 2021
10
11

Click a cell to add it to your formula, drag to select a range, or click a column letter for the whole column.

Always use 0 for an exact match

MATCH's last argument sets how it searches:

  • 0: an exact match. The list can be in any order.
  • 1, or left out: the largest value less than or equal to lookup_value. The list must be sorted smallest to largest.
  • -1: the smallest value greater than or equal to lookup_value. The list must be sorted largest to smallest.

Because the default is 1, forgetting the 0 gives you an approximate match. The IDs in column A happen to be sorted, so look what happens with an ID that doesn't exist:

=INDEX(B2:B9, MATCH("E109", A2:A9))→ Sam Okafor
=INDEX(B2:B9, MATCH("E109", A2:A9, 0))→ #N/A

The approximate version settles for E108 and returns a believable but wrong name. On unsorted data, like the names, it can also miss values that are there. For IDs, names and codes, always end MATCH with 0.

Keep the ranges lined up

INDEX trusts MATCH's position completely. If the two ranges start on different rows, you get a wrong answer with no error. Here the INDEX range starts at the header:

=INDEX(C1:C9, MATCH("Lena Fischer", B2:B9, 0))→ Finance

Position 7 of C1:C9 is C7, Tom Becker's department. Make both ranges cover the same rows, such as B2:B9 and C2:C9.

Look up a value to the left

VLOOKUP can only return columns to the right of the one it searches. INDEX and MATCH can return from any column, so finding an ID from a name is easy:

=INDEX(A2:A9, MATCH("Diego Ruiz", B2:B9, 0))→ E104

And because you point at the return column instead of counting columns, inserting a column doesn't break the formula. Excel adjusts the ranges for you.

Lock the ranges before copying down

With names in K2:K4, put this in L2 and copy it down to get each person's department:

=INDEX($C$2:$C$9, MATCH(K2, $B$2:$B$9, 0))

K2 changes to K3 and K4, but the dollar signs keep both ranges fixed. With Grace Kim, Omar Haddad and Lena Fischer in K2:K4, you get Marketing, Finance and IT. Without the dollar signs, the ranges slide down a row each time, so names near the top drop out and return #N/A.

Two-way lookups with INDEX, MATCH and MATCH

INDEX can take a row number and a column number. Give it the whole table and let one MATCH find the row and another find the column. This finds Hannah Lee's salary by matching her name down column B and the "Salary" header across row 1:

=INDEX(A2:E9, MATCH("Hannah Lee", B2:B9, 0), MATCH("Salary", A1:E1, 0))→ $52,000

The row MATCH returns 1 and the column MATCH returns 4, so INDEX returns row 1, column 4 of A2:E9, which is cell D2. Swap "Salary" for "Department" and it returns Sales. B2:B9 must cover the same rows as A2:E9, and A1:E1 the same columns.

This isn't the same as a lookup with multiple criteria, where two conditions must both be true in one row. That needs a different formula.

How to fix #N/A and #REF!

#N/A means MATCH found nothing. Check these:

  1. The 0. Without it, MATCH does an approximate match.
  2. Extra spaces. "Lena Fischer " won't match "Lena Fischer". Clean the data with TRIM, or use =MATCH(TRIM(K2), B2:B9, 0).
  3. Numbers stored as text. The number 1002 doesn't match the text "1002". Use VALUE(K2) if the column holds numbers, or K2&"" if it holds text.
  4. A genuinely missing value. Show a message with IFNA (Excel 2013 and later), which still lets other errors show:
=IFNA(INDEX(C2:C9, MATCH("Ana Lopez", B2:B9, 0)), "Not found")→ Not found

#REF! means INDEX was asked for a position outside its range, usually because the MATCH range is longer:

=INDEX(C2:C5, MATCH("Lena Fischer", B2:B9, 0))→ #REF!

MATCH returns 7, but C2:C5 has only 4 cells. Use ranges of the same size.

Duplicates and upper or lower case

MATCH returns the first match only. Sales appears twice in column C, but you only get the first person:

=INDEX(B2:B9, MATCH("Sales", C2:C9, 0))→ Hannah Lee

Diego Ruiz is in Sales too. To check for repeats, use COUNTIF: =COUNTIF(C2:C9, "Sales") returns 2. To list every match, use FILTER in Microsoft 365 or Excel 2021 and later.

MATCH also ignores case, so "lena fischer" finds Lena Fischer. A case-sensitive lookup needs a formula built on the EXACT function.

INDEX MATCH vs XLOOKUP and VLOOKUP

INDEX and MATCH work in Excel 2016 and 2019 as well as Excel 2021, Excel 2024, Microsoft 365 and Excel for the web. XLOOKUP isn't available in Excel 2016 or 2019. If everyone using the file has Microsoft 365 or Excel 2021 or later, XLOOKUP is shorter, exact by default and has a built-in "not found" argument:

=XLOOKUP("Lena Fischer", B2:B9, C2:C9)→ IT

See the XLOOKUP guide. VLOOKUP works in every version but can't look left, and the VLOOKUP guide covers it. For Microsoft's own examples, see Look up values in a list of data.

For more practice, the lookups topic has Premium exercises on MATCH on its own, INDEX and MATCH and a two-way lookup.

Key takeaways

  • MATCH returns a position inside its range, not a sheet row. INDEX returns the item at that position.
  • Use =INDEX(return_range, MATCH(lookup_value, lookup_range, 0)) and don't leave out the 0.
  • Keep both ranges on the same rows, and lock them with dollar signs before copying down.
  • Two MATCHes give you a two-way lookup. In Microsoft 365 or Excel 2021 and later, XLOOKUP is simpler.

Practice

Keep going with INDEX and MATCH exercises

Reading gets you started. Solving a few of these is what makes it stick.

  1. 1Find a salaryFreeWhat is Priya Shah's salary?→
  2. 2MATCH on its own PremiumIn which position in the name list (B2:B9) is Sam Okafor?→
  3. 3INDEX and MATCH PremiumFind the name of employee E103 using INDEX and MATCH.→
  4. 4Look to the left PremiumWhat is Hannah Lee's ID? The ID column is to the left of the names, so VLOOKUP can't do this one.→
  5. 5Two-way lookup PremiumFind the value for employee E102 in the column headed Start date. Use MATCH for both the row and the column, so the formula keeps working if the columns move.→
All lookups exercises →
Brian Millot

About the author

Brian Millot

Brian Millot is an indie hacker based in France who builds small, focused web products. He built and runs Excel Formula Practice, from the in-browser spreadsheet that checks your formulas to the exercise library, and he writes the formula guides.

Related guides

Practice makes formulas

Stop reading. Start typing formulas.

Every exercise is a real spreadsheet with instant feedback. The first two in every topic are free, no sign-up needed.