Topic 05
XLOOKUP
XLOOKUP was built as a direct answer to VLOOKUP's three problems. Same job — find a value and return something from the same row — but every limitation has been removed. You'll use the same file and same Search sheet, this time filling the xlookup column.
Three Problems — Three Solutions
Each VLOOKUP limitation has a direct fix in XLOOKUP. The left side shows the problem; the right shows how XLOOKUP addresses it.
Search any column — not just the leftmost
=XLOOKUP($G$3, table1[ID], table1[name])
=XLOOKUP($G$3, table1[name], table1[Salary])
Return by column name — not by index number
=VLOOKUP($G$3, table1, 7, 0)
What is column 7? You have to count.
=XLOOKUP($G$3, table1[ID], table1[Hire Date])
Self-documenting. No counting.
Exact match by default — no forgotten argument
TRUE). Forgetting to add 0 returns wrong results with no warning.
=VLOOKUP($G$3, table1, 2)
Dangerous — approximate match active.
=XLOOKUP($G$3, table1[ID], table1[name])
Safe by default. Clean and readable.
XLOOKUP Syntax
$G$3 so it stays fixed when you copy the formula down.
table1[ID].
table1[name], table1[Salary], etc. This is what replaces the column index number.
#N/A error — e.g. "Not found". If omitted, Excel returns #N/A.
0 = exact match (default — no need to write it). -1 = exact or next smaller. 1 = exact or next larger. Used in VLOOKUP approximate topics.
1 = first to last (default). -1 = last to first. Useful when you want the most recent match.
Training Exercise
Two exercises this topic. First, rewrite the three students formulas from Topic 04 — replacing the column numbers with column names. Then fill the XLOOKUP column in lookup.xlsx.
Quick Callback — students.xlsx
In Topic 04 you wrote VLOOKUP(A6, students, 3, 0), ...7, 0, and ...8, 0). Rewrite all three using XLOOKUP — no column numbers, just column names.
| Field | VLOOKUP (Topic 04) | XLOOKUP (now) |
|---|---|---|
| Name | VLOOKUP(A6, students, 3, 0) |
=XLOOKUP(A6, students[ID], students[First Name]) |
| GPA | VLOOKUP(A6, students, 7, 0) |
=XLOOKUP(A6, students[ID], students[GPA]) |
| Fees | VLOOKUP(A6, students, 8, 0) |
=XLOOKUP(A6, students[ID], students[Fees]) |
Now open lookup.xlsx and go to the Search sheet. The vlookup column is already filled from Topic 04. Now fill the xlookup column for all 10 fields. Compare both columns side by side — they should return identical results for every selected ID.
Download lookup.xlsx| Field | XLOOKUP Formula |
|---|---|
| ID | =XLOOKUP($G$3, table1[ID], table1[ID]) |
| name | =XLOOKUP($G$3, table1[ID], table1[name]) |
| Building | =XLOOKUP($G$3, table1[ID], table1[Building]) |
| Department | =XLOOKUP($G$3, table1[ID], table1[Department]) |
| Phone | =XLOOKUP($G$3, table1[ID], table1[Phone]) |
| Status | =XLOOKUP($G$3, table1[ID], table1[Status]) |
| Hire Date | =XLOOKUP($G$3, table1[ID], table1[Hire Date]) |
| Years | =XLOOKUP($G$3, table1[ID], table1[Years]) |
| Benefits | =XLOOKUP($G$3, table1[ID], table1[Benefits]) |
| Salary | =XLOOKUP($G$3, table1[ID], table1[Salary]) |
$G$3 and table1[ID]. Only the return column name changes — no counting, no numbers. If the HR List gains a new column tomorrow, not a single formula breaks.
This applies to both functions equally. XLOOKUP's
[search_mode] argument lets you choose between first-to-last or last-to-first — but it still returns only one result.