Google Sheets recipe
How to use INDEX and MATCH in Google Sheets
Write =INDEX(result_column, MATCH(key, key_column, 0)). MATCH returns the position of the key and INDEX returns the cell at that position, so the result column can sit left or right of the key column.
Steps
- Pick the column that holds the answer, for example D2:D6 for salaries.
- Pick the column that holds the key, for example A2:A6 for IDs. Both ranges should have the same number of rows, so the positions line up.
- Write MATCH(key, A2:A6, 0). The 0 asks for an exact match.
- Wrap it in INDEX: =INDEX(D2:D6, MATCH(103, A2:A6, 0)).
- For a table lookup use INDEX(A1:D6, row_match, column_match) with one MATCH for the row and one for the column.
- Wrap the whole formula in IFERROR when the key may be missing.
Examples
The examples use this table, starting in A1:
| ID | Name | Team | Salary |
| 101 | Maria | Sales | 4200 |
| 102 | Andrei | Ops | 3800 |
| 103 | Maria | Ops | 5100 |
| 104 | Dan | Ops | 3600 |
| 105 | Elena | HR | 4500 |
=INDEX(A2:A6, MATCH("Elena", B2:B6, 0))Result: 105
A lookup to the left: the ID sits in column A, the name in column B. VLOOKUP searches only the first column of its range, so it would not find a name in B. INDEX with MATCH has no such limit.
Run in a Google Sheet (English US locale) on .
=INDEX(D2:D6, MATCH(103, A2:A6, 0))Result: 5100
MATCH finds the row position of ID 103 inside A2:A6. INDEX returns the salary from that same position in D2:D6.
Run in a Google Sheet (English US locale) on .
=INDEX(D2:D6, MATCH(1, (B2:B6="Maria")*(C2:C6="Ops"), 0))Result: 5100
Two criteria: each comparison gives TRUE or FALSE, the product is 1 only where both hold, and MATCH looks for that 1. There are two Marias, so one criterion alone is not enough.
Run in a Google Sheet (English US locale) on .
=INDEX(A1:D6, MATCH("Dan", B1:B6, 0), MATCH("Salary", A1:D1, 0))Result: 3600
Row and column both found by MATCH: Dan's row crossed with the Salary column.
Run in a Google Sheet (English US locale) on .
=IFERROR(INDEX(D2:D6, MATCH("Zoe", B2:B6, 0)), "not found")Result: not found
A name that is not in the list. IFERROR turns the #N/A from MATCH into your own text.
Run in a Google Sheet (English US locale) on .
=XLOOKUP("Elena", B2:B6, A2:A6, "none")Result: 105
The same left lookup in one function. XLOOKUP takes the search column and the result column separately.
Run in a Google Sheet (English US locale) on .
Common errors
- Leave out the 0 and MATCH assumes 1, an approximate match meant for sorted data. On an unsorted list it returns a position without any error, so the answer can be wrong.
- MATCH returns only the first hit. With two Marias in the list, a name alone always lands on the first one, so add a second criterion.
- A row number past the end of the range makes INDEX return #NUM!, for example INDEX(D2:D6, 9) on five rows.
- A number typed as text does not match a real number: MATCH("103", A2:A6, 0) returns #N/A while MATCH(103, A2:A6, 0) works.
Questions and answers
Should I use INDEX MATCH or XLOOKUP?
Both do a left lookup. XLOOKUP is shorter and takes a value to return when the key is missing. With INDEX, a row or column argument of 0 returns the whole row or column: =COUNTA(INDEX(A2:D6, 3, 0)) counts the 4 cells of the third row.
How do I find the row of a value?
Use MATCH alone: =MATCH("Dan", B2:B6, 0) returns 4, the position inside the range, not the sheet row number.
Compared with Excel
INDEX and MATCH work the same way in Excel. XLOOKUP exists in Excel 365 and Excel 2021, not in older versions.