Lookups

How to Use INDEX and MATCH Together

How to use INDEX and MATCH together in Excel for lookups to the left, two-way lookups and tables whose columns may change, with formula examples.

On this page
  1. What each function does
  2. A basic lookup
  3. Look up to the left
  4. A two-way lookup
  5. Match type and common mistakes

INDEX and MATCH are two functions that work well together. MATCH finds where a value sits in a list. INDEX returns the value at a given position. Combined, they can look up a value in any column, whether it is to the left or the right of the column you are matching on.

What each function does

MATCH takes a value, a list and a match type, and returns the position of the value in that list, counting from 1:

=MATCH(lookup_value, lookup_array, 0)

INDEX takes a range and a position, and returns the value at that position:

=INDEX(range, row_num)

For example, if the names “Lee” and “Patel” are in A2:A6 and Lee is the third name, MATCH(“Lee”, A2:A6, 0) returns 3. INDEX(B2:B6, 3) then returns the third value in column B.

A basic lookup

Suppose names are in A2:A20 and scores are in B2:B20. To get the score for the name typed in D2:

=INDEX(B2:B20, MATCH(D2, A2:A20, 0))

Read it from the inside out. MATCH finds the position of D2 in the names. INDEX then returns the value in the score column at that same position.

Look up to the left

The score column does not need to be on the right of the names. Suppose the order numbers are in column C and the customer names are in column A, and you have an order number in F2 that you want to turn into a name:

=INDEX(A2:A50, MATCH(F2, C2:C50, 0))

MATCH searches column C, which is the column you are matching on, and INDEX returns from column A. Because INDEX picks the column by position, the order of the columns does not matter.

A two-way lookup

A two-way lookup finds a value where a row label meets a column label. Suppose products are listed down column A from row 2 to row 10, months are across row 1 from column B to column E, and the sales figures fill the grid between them. The product is in H2 and the month is in H3:

=INDEX(B2:E10, MATCH(H2, A2:A10, 0), MATCH(H3, B1:E1, 0))

The first MATCH finds the row for the product. The second finds the column for the month. INDEX uses both positions to return the figure where they cross.

Match type and common mistakes

  • Always type 0 as the third argument of MATCH. If you leave it out, MATCH assumes 1, which is an approximate match and needs a sorted list. That causes the same wrong-answer problem described in exact vs approximate match in VLOOKUP.
  • Keep the ranges the same size. The range you return from in INDEX and the range you search in MATCH should be the same length and start on the same row or column.
  • Expect #N/A when the value is missing. MATCH returns #N/A if the value is not in the list. Use IFNA around the formula if you want a blank instead.

MATCH is not case sensitive, so “smith” and “Smith” are treated as the same value.

Compared with XLOOKUP, INDEX and MATCH take more typing, but they work in every version of Excel. How to use xlookup in excel covers the newer function.

The complete guide to lookups

How to Look Up Data in Excel
Read the guide

Keep exploring

Guides from other topics

All topics →