XLOOKUP in Google Sheets finds a value in one column or row and returns the matching entry from another. This guide covers the basic formula, looking up a column to the left, showing your own text instead of #N/A, and finding the last match instead of the first.
The XLOOKUP syntax that applies to Sheets
Google's XLOOKUP help page gives the Sheets syntax as:
XLOOKUP(search_key, lookup_range, result_range, missing_value, match_mode, search_mode)
The page describes each argument this way:
- search_key: the value to find, such as
42,"Cats"or a cell likeB24. - lookup_range: where to search. It must be a single row or a single column.
- result_range: what to return. Its row or column size should match
lookup_range. - missing_value (optional): what to return when nothing matches. The default is
#N/A. - match_mode (optional, default
0):0is an exact match and2is a wildcard match.1and-1are approximate options, covered below. - search_mode (optional, default
1):1searches first to last,-1searches last to first,2is a binary search on a range sorted ascending,-2is a binary search on a range sorted descending.
Write a basic XLOOKUP
- Click the cell where you want the result.
- Type
=XLOOKUP(followed by the value to find, the column to search, and the column to return. - Press Enter.
This formula looks up "Apple" in column A and returns the value from column E:
=XLOOKUP("Apple", A2:A, E2:E)
Swap "Apple" for a cell reference if you want the lookup to change with your input. A drop-down list in that cell makes a tidy picker.
Look up a column to the left
XLOOKUP has no such rule because the lookup and result ranges are separate arguments. This formula searches column E and returns column A:
=XLOOKUP("Apple", E2:E7, A2:A7)
Replace #N/A with your own text
Put your message in the fourth argument, missing_value:
=XLOOKUP("Apple", A2:A, E2:E, "Not found")
If "Apple" isn't in column A, the cell shows "Not found" instead of #N/A. Coupler's guide uses the same pattern with a message like "No office there". You can also use an empty string "" to leave the cell blank.
Find the last match instead of the first
By default XLOOKUP searches top to bottom and stops at the first hit. Set search_mode to -1 to search from the bottom up, which gives you the last occurrence.
=XLOOKUP("Apple", A2:A, E2:E, "Not found", 0, -1)
If you're not sure whether your list has repeats, highlight duplicates with COUNTIF first.
Approximate and wildcard matches
For an approximate match, set match_mode to 1 or -1. Guides describe the direction of these two options differently, so test which way each one rounds on your own data before relying on it:
=XLOOKUP(B2, A2:A, E2:E, "No band", -1)
For a wildcard match, set match_mode to 2. Google's page does not list which wildcard characters it accepts, so check the behaviour in your own sheet before relying on it.
The binary search options (search_mode 2 and -2) only belong on ranges sorted ascending or descending respectively. Don't use them on unsorted data.
When XLOOKUP returns an error
The most common cause is mismatched ranges. lookup_range must be a single row or column, and result_range should be the same size. A formula like XLOOKUP("Apple", A2:A7, E2:E) mixes a fixed range with an open-ended one. Make both ranges start and end on the same rows, or make both open-ended.
If you get #N/A on a value you can see, the default exact match is doing its job: the cell contents differ somehow from the search key. Add a missing_value so the result is readable while you check the data.