Sub topic 1
What a lookup does and why XLOOKUP
Prerequisites
This chapter assumes you can enter and copy Excel formulas and understand cell references, ranges, and absolute references such as $E$2. You also need Excel for Microsoft 365, Excel 2021 or later, or Excel for the web.
What a lookup does and why XLOOKUP
A lookup finds a value in one range and returns related data from another range. For example, a product table might contain product IDs in column A and prices in column C. If cell E2 contains a product ID, a lookup can return its price.
XLOOKUP is Excel’s modern lookup function. Unlike VLOOKUP, it can search in any direction. It also uses exact matching by default, can return multiple columns, and provides a direct argument for missing results.
flowchart LR
A[Lookup value in E2] --> B[Search product IDs in A2:A10]
B --> C[Find matching row]
C --> D[Return price from C2:C10]XLOOKUP syntax: the six arguments
The complete syntax is:
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])| Argument | Purpose |
|---|---|
| `lookup_value` | The value to find |
| `lookup_array` | The range to search |
| `return_array` | The range containing the result |
| `if_not_found` | Optional result when no match exists |
| `match_mode` | Optional exact, approximate, or wildcard behavior |
| `search_mode` | Optional search direction or binary search |
Exact match: the default behavior
XLOOKUP uses an exact match by default. This formula searches A2:A10 for the value in E2 and returns the value from the corresponding row in C2:C10.
=XLOOKUP(E2, A2:A10, C2:C10)The lookup and return ranges should have compatible sizes. If several rows match, XLOOKUP returns the first match unless you change the search mode.
Replacing #N/A with a custom result
When no exact match exists, XLOOKUP normally returns #N/A. Use the fourth argument to return a clearer result:
=XLOOKUP(E2, A2:A10, C2:C10, "Not found")Common causes of unexpected #N/A include leading or trailing spaces, different spelling, and numbers stored as text. #VALUE! often indicates incompatible range dimensions or an invalid argument.
Exercise
Write a formula that looks for the ID in E2 within A2:A10 and returns the matching value from C2:C10, displaying "Missing" when no match exists.
Show answer
=XLOOKUP(E2, A2:A10, C2:C10, "Missing")