# XLOOKUP in Google Sheets: syntax and examples

URL: https://goingstellar.ro/reference/sheets/xlookup/

XLOOKUP searches one range and returns the value from the same position in another. It looks in either direction, takes a fallback for misses, and can return the first or the last match. It covers what VLOOKUP, HLOOKUP and INDEX with MATCH did separately.

## Syntax

```
XLOOKUP(search_key, lookup_range, result_range, missing_value, [match_mode], [search_mode])
```

## Arguments

- `search_key` (any, required: yes): The value to find.
- `lookup_range` (range, required: yes): One row or column to search. It can sit anywhere, left or right of the result.
- `result_range` (range, required: yes): What to return, same height or width as lookup_range. A wider range returns the whole row.
- `missing_value` (any, required: no): Returned when nothing matches. Left out, a miss gives #N/A.
- `match_mode` (number, required: no): 0 exact (default), -1 exact or next smaller, 1 exact or next larger, 2 wildcard.
- `search_mode` (number, required: no): 1 first to last (default), -1 last to first, 2 or -2 binary search on sorted data.

## Examples

The examples use this table, starting in A1:

| SKU | Product | Price | Stock |
|---|---|---|---|
| A-100 | Desk lamp | 34 | 12 |
| A-200 | Office chair | 549 | 0 |
| B-300 | Monitor stand | 129.5 | 7 |
| B-400 | Cable tray | 79.9 | 40 |
| A-100 | Desk lamp XL | 99 | 3 |

```
=XLOOKUP("Cable tray", B2:B6, A2:A6)
```

Result: `B-400`

The key is in column B and the result in column A. XLOOKUP looks left, VLOOKUP cannot. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=XLOOKUP("C-999", A2:A6, C2:C6, "not found")
```

Result: `not found`

A fourth argument replaces #N/A, so no IFERROR is needed. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=XLOOKUP("A-100", A2:A6, B2:B6, "", 0, -1)
```

Result: `Desk lamp XL`

The code appears twice. search_mode -1 starts from the bottom and returns the last one. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=XLOOKUP(100, C2:C6, B2:B6, "", 1)
```

Result: `Monitor stand`

match_mode 1 finds the exact price or the next larger one: 129.5, Monitor stand. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=XLOOKUP("B-*", A2:A6, B2:D6, "", 2)
```

Result: 

| Monitor stand | 129.5 | 7 |
|---|---|---|


A wildcard needs match_mode 2. A wider result_range returns the whole row across. Run in a Google Sheet (English US locale) on 2026-11-29.

## Common errors

- Without missing_value a miss returns #N/A. Put your own text as the fourth argument, or an empty string "" to skip it before match_mode.
- Wildcards (* and ?) work only with match_mode 2. In the default mode, "B-*" is searched as literal text and returns #N/A.
- lookup_range and result_range must have the same length. B2:B5 against A2:A6 returns #N/A.
- With duplicates the first match wins. Use search_mode -1 to take the last one.

## Compared with Excel

Same syntax as Excel XLOOKUP. Excel names the fourth argument if_not_found.

## Related functions

- [VLOOKUP](https://goingstellar.ro/reference/sheets/vlookup/)
- [HLOOKUP](https://goingstellar.ro/reference/sheets/hlookup/)
- [MATCH](https://goingstellar.ro/reference/sheets/match/)
- [INDEX](https://goingstellar.ro/reference/sheets/index/)
- [IFNA](https://goingstellar.ro/reference/sheets/ifna/)
- [LOOKUP](https://goingstellar.ro/reference/sheets/lookup/)

## Sources

- [XLOOKUP (Docs Editors Help)](https://support.google.com/docs/answer/12405947)

