Skip to content

INDEX MATCH in Excel

Lookup · Updated

Purpose
Find the position of a value in one column, then return the item at that position from another column.
Returns
The matching value, or #N/A if nothing matches.
Syntax
fx=INDEX(return_range, MATCH(lookup_value, lookup_range, 0))
Works in
Every version of Excel · Microsoft 365 · Google Sheets · LibreOffice Calc

Arguments

ArgumentRequiredWhat it is
return_rangeYesThe column that holds the value you want back. This is the first argument of INDEX.
lookup_valueYesThe value to search for. This is the first argument of MATCH.
lookup_rangeYesThe single column to search. It must start and end on the same rows as return_range.
0NoThe match type of MATCH. 0 finds an exact match. If you leave it out, MATCH uses 1, an approximate match that needs data sorted ascending, so always type the 0.

Example: find the tutor for a course

MATCH finds the course in E2 in column A and reports its position in the list, 4. INDEX then returns the fourth item of column C.

F2fx=INDEX(C2:C6, MATCH(E2, A2:A6, 0))
ABCDEF
1CourseRoomTutorFind courseTutor
2AlgebraR12Mr OseiHistoryMrs Dunn
3BiologyLab 2Ms Park
4ChemistryLab 1Dr Singh
5HistoryR07Mrs Dunn
6PhysicsLab 3Mr Alvarez

Build your INDEX MATCH formula

Fill in the fields with your own cells. The formula updates as you type.

Same height as the return column.
Your formula
F2fx=INDEX(C2:C6, MATCH(E2, A2:A6, 0))

MATCH finds the position of E2 in A2:A6; INDEX returns the value at that position in C2:C6.

Paste the formula into cell F2 or any empty cell. The coloured parts match the coloured fields. Using a different list separator? Replace the commas with semicolons.

How INDEX MATCH works

INDEX MATCH is two functions, one inside the other. Each does half of a lookup.

  • MATCH searches a column for a value and returns its position as a number. If “History” is the fourth item in A2:A6, MATCH("History", A2:A6, 0) returns 4.
  • INDEX returns the item at a given position in a range. INDEX(C2:C6, 4) returns the fourth cell of C2:C6, which is C5.

Put MATCH where INDEX expects the position and you have a lookup: MATCH finds the row, INDEX fetches the value from that row.

Because the two ranges are separate, the return column can be to the left or right of the search column. Nothing counts columns, so inserting a column between them does not change the result.

The match type

The third argument of MATCH decides how the search is done.

Match type Behaviour Data must be
0 Finds the first value that is exactly equal to the lookup value. In any order.
1 or left out Finds the largest value that is less than or equal to the lookup value. Sorted ascending.
-1 Finds the smallest value that is greater than or equal to the lookup value. Sorted descending.

Type the 0 every time you want an exact match. Leaving it out is the most common cause of wrong results, because the default is 1.

With match type 0 you can use wildcards in a text lookup value. An asterisk matches any text and a question mark matches one character.

More examples

Look up a row and a column

With names in A2:A6, month headers in B1:D1 and figures in B2:D6:

=INDEX(B2:D6, MATCH(G1, A2:A6, 0), MATCH(G2, B1:D1, 0))

returns the figure where the row for the name in G1 meets the column for the month in G2. INDEX takes a row number and then a column number.

Match on two columns

=INDEX(C2:C50, MATCH(1, (A2:A50=F1)*(B2:B50=F2), 0))

returns the column C value from the first row where column A equals F1 and column B equals F2. In Excel 2019 and earlier, press Ctrl+Shift+Enter to confirm it.

Find a band with an approximate match

With score boundaries 0, 60, 70, 80, 90 in A2:A6 and grades F, D, C, B, A in B2:B6:

=INDEX(B2:B6, MATCH(84, A2:A6, 1))

returns B, because 80 is the largest boundary that does not exceed 84.

Show a message when nothing is found

=IFERROR(INDEX(C2:C6, MATCH(E2, A2:A6, 0)), "Not found")

returns “Not found” in place of #N/A when the value in E2 is not in column A.

Tips

  • Make the return range and the lookup range the same height, starting on the same row. MATCH reports a position inside its own range, and INDEX counts from the top of its own range.
  • Lock both ranges with dollar signs ($C$2:$C$6) before copying the formula down.
  • MATCH returns the first match only. If the lookup column has repeats, later rows are never reached.
  • A number and a text value that looks like a number do not match. Convert one side so both are the same type.
  • To look across a row, pass MATCH a single row and give INDEX a row as well. The same formula then replaces HLOOKUP.
  • MATCH is useful alone. =ISNUMBER(MATCH(E2, A2:A6, 0)) returns TRUE when the value in E2 appears in the list.

INDEX MATCH or VLOOKUP

VLOOKUP is the shorter formula when the search column is the first column of the table and the column you want is to its right. It takes one range and a column number.

INDEX MATCH is the better choice in three cases:

  • The value you want is to the left of the search column.
  • Columns are likely to be inserted or moved. A VLOOKUP column number does not update, and the formula starts returning the wrong column.
  • You need a two-way lookup on a row label and a column header.

Both formulas work in every version of Excel, in Google Sheets and in LibreOffice Calc. If all your readers have Excel 2021 or Microsoft 365, XLOOKUP does the same job in one function.

To build the formula from your own cell references, use the INDEX MATCH generator.

Errors and fixes

ErrorWhy it happensFix
#N/AMATCH found no exact match in the lookup range.Check spelling, extra spaces and numbers stored as text. Wrap the formula in IFERROR to show your own message.
#REF!The return range is shorter than the lookup range, and the match is below its last row.Give both ranges the same first and last row.
Wrong resultThe third argument of MATCH is missing, so MATCH does an approximate match on data that is not sorted.Add 0 as the third argument of MATCH.
Value from the wrong rowThe two ranges start on different rows, for example C1:C6 and A2:A6.Start both ranges on the same row.

Questions

Is INDEX MATCH better than VLOOKUP?

It does more. It can return a column to the left of the search column, it keeps working when columns are inserted, and it can look up a row and a column at once. VLOOKUP is shorter to type and easier to read. Both exist in every version of Excel.

What does the 0 in MATCH mean?

It asks for an exact match. With 1, or with the argument left out, MATCH returns the position of the largest value that is less than or equal to the lookup value, and the range must be sorted ascending. With -1 it returns the smallest value that is greater than or equal to the lookup value, and the range must be sorted descending.

Can INDEX MATCH use multiple criteria?

Yes. Multiply the tests and match the number 1: =INDEX(C2:C50, MATCH(1, (A2:A50=F1)*(B2:B50=F2), 0)). In Excel 2019 and earlier, confirm the formula with Ctrl+Shift+Enter.

Can INDEX MATCH look to the left?

Yes. The return range and the lookup range are independent, so the return column can be anywhere, including to the left of the search column or on another sheet.

Is INDEX MATCH case-sensitive?

No. MATCH treats "abc" and "ABC" as the same value. For a case-sensitive lookup use =INDEX(C2:C6, MATCH(TRUE, EXACT(A2:A6, E2), 0)), confirmed with Ctrl+Shift+Enter in Excel 2019 and earlier.

Should I use INDEX MATCH or XLOOKUP?

Use XLOOKUP when every reader has Excel 2021 or Microsoft 365. It is one function and has a built-in "if not found" argument. Use INDEX MATCH when the file must also open in Excel 2019 or earlier.

Related