INDEX + MATCH: the flexible lookup

Lesson 20 of 54

INDEX and MATCH work together as a lookup: MATCH finds the row where a value sits, and INDEX returns the value in that row from another column. It works in every version of Excel and in Google Sheets, and it can look left.

In cell F2, write a formula with INDEX and MATCH that returns the Stock for the product named in E2.

F2
ABCDEF
1StockProductPriceProductStock
242Notebook3.5Folder
3130Pen1.25
418Folder2.1
564Marker1.75

Type in the formula bar above and press Enter to check.

Skip

How INDEX and MATCH work

Syntax

=INDEX(return_range, MATCH(search_key, lookup_range, 0))
return_range
The column that holds the answer you want back.
search_key
The value you are looking for, usually a cell like E2.
lookup_range
The column to search in. Same rows as return_range.
0
Tells MATCH to find an exact match. Almost always what you want.

Example

Employee IDs are in C2:C200 and email addresses in A2:A200 (to the left of the IDs). You type an ID in H2.

=INDEX(A2:A200, MATCH(H2, C2:C200, 0))

MATCH finds the row of that ID, and INDEX returns the email from the same row, even though the email column is to the left.

Common mistakes

  • Leaving out the 0 in MATCH. Without it, MATCH guesses an approximate match and needs sorted data, so it can return the wrong row.
  • Ranges that start on different rows (A2:A200 and C1:C199). The row MATCH finds then points to the wrong place in INDEX.
  • Swapping the ranges: INDEX gets the column you want back, MATCH gets the column you search in.

Questions people ask

Is INDEX MATCH better than VLOOKUP?

It is more flexible: it can look left, it doesn't break when you insert a column, and it only reads the two columns it needs. In Excel 365 and Google Sheets, XLOOKUP does the same job in one function.

How do I do INDEX MATCH with two conditions?

Match on a combined condition: =INDEX(C2:C100, MATCH(1, (A2:A100=G1)*(B2:B100=G2), 0)). In older Excel, confirm it with Ctrl+Shift+Enter.

Practice it above: type the formula in the formula bar and press Enter to check.