# How to use INDEX and MATCH in Google Sheets

URL: https://goingstellar.ro/reference/sheets/recipes/index-match/

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

1. Pick the column that holds the answer, for example D2:D6 for salaries.
2. 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.
3. Write MATCH(key, A2:A6, 0). The 0 asks for an exact match.
4. Wrap it in INDEX: =INDEX(D2:D6, MATCH(103, A2:A6, 0)).
5. For a table lookup use INDEX(A1:D6, row_match, column_match) with one MATCH for the row and one for the column.
6. 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 2026-11-29.

```
=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 2026-11-29.

```
=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 2026-11-29.

```
=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 2026-11-29.

```
=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 2026-11-29.

```
=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 2026-11-29.

## 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.

## Functions used

- [INDEX](https://goingstellar.ro/reference/sheets/index/)
- [MATCH](https://goingstellar.ro/reference/sheets/match/)
- [XLOOKUP](https://goingstellar.ro/reference/sheets/xlookup/)
- [IFERROR](https://goingstellar.ro/reference/sheets/iferror/)

## Sources

- [INDEX (Docs Editors Help)](https://support.google.com/docs/answer/3098242)
- [MATCH (Docs Editors Help)](https://support.google.com/docs/answer/3093378)
- [XLOOKUP (Docs Editors Help)](https://support.google.com/docs/answer/12405947)
- [IFERROR (Docs Editors Help)](https://support.google.com/docs/answer/3093304)

