Lesson 5 of 8 · see all lessons
Formulas from zero
Answer questions with conditions and lookups
Organize and summarize the month
12 min
How to use XLOOKUP in Excel (and VLOOKUP when you have to)
XLOOKUP finds a value in one column and returns the matching value from another. Learn it step by step, fix #N/A, and read an old VLOOKUP.
By the end of this lesson you can
- Write XLOOKUP with its three required parts
- Fill a lookup down a column with $ on the lookup ranges
- Turn #N/A into a clear message, and find the first or last match
- Read and repair a VLOOKUP someone else wrote
From earlier lessons · 1 of 2
Which formula adds the Totals of coffee rows?
Pick one answer.
From earlier lessons · 2 of 2
What does ">="&DATE(2026,3,16) do as a SUMIFS criterion?
Pick one answer.
The café's costs live in a separate menu list. Typing 30 costs into the sales rows by hand means 30 chances for a typo. A lookup fetches each one for you, and tells you when it can't find one.
Take a guess
You ask a lookup for the cost of a Mocha. The menu has no Mocha. What does XLOOKUP return if you give it nothing else?
No pressure. Guess now, and the lesson will show you if you were right.
Paste the menu
The café's costs sit in a small menu list: what one unit of each item costs the café to make. Copy the block below and paste it into cell S1. Column R stays empty so the menu stays separate from the sales rows.
Menu item Unit costEspresso 0.60Latte 0.90Cappuccino 0.85Green Tea 0.40Chai 0.70Croissant 1.10Muffin 1.00Sandwich 3.20
XLOOKUP in three parts
XLOOKUP searches one column for a value and returns the value from the same row of another column. Three parts are required:
- lookup_value: what to find, such as the item in C2
- lookup_array: where to search, the menu items S2:S9
- return_array: what to bring back, the costs T2:T9
It looks for an exact match by default. XLOOKUP isn't in Excel 2016 or 2019. It is in Microsoft 365, Excel 2021 and later, and Google Sheets (checked November 2026).
Put in order
Put the parts of the cost lookup in order.
Drag, or focus an item and press Space, move with the arrow keys, then Space to drop.
- C2
- =XLOOKUP(
- ,$T$2:$T$9
- ,$S$2:$S$9
- )
M1: Unit costM2: =XLOOKUP(C2,$S$2:$S$9,$T$2:$T$9) (fill down to M31)N1: ProfitN2: =E2*(F2-M2) (fill down)P15: Profit Q15: =SUM(N2:N31)
Step through
XLOOKUP("Chai", S2:S9, T2:T9): scanning the menu for row 11
- Espresso0look
- Latte1
- Cappuccino2
- Green Tea3
- Chai4
- Croissant5
- Muffin6
- Sandwich7
Start at the top. Espresso isn't Chai.
Why do the menu ranges in M2 need $ signs, but C2 doesn't?
Pick one answer.
=XLOOKUP("Mocha",$S$2:$S$9,$T$2:$T$9,"Not on menu")
Look things up in the sales rows
XLOOKUP stops at the first match, searching from the top. The sixth part, search_mode, changes direction: -1 searches from the last row up. And the return column can sit anywhere, even to the left of the column you search.
=XLOOKUP("Sandwich",C2:C31,G2:G31)=XLOOKUP("Sandwich",C2:C31,G2:G31,"none",0,-1)=XLOOKUP("Sandwich",C2:C31,A2:A31)
VLOOKUP, for older files
You'll meet VLOOKUP in older workbooks. It searches the first column of a table and returns the column you name by number, counting from 1. Its last part matters most: FALSE means exact match. Leave it out and VLOOKUP uses approximate match, which expects a sorted first column.
=VLOOKUP(C2,$S$2:$T$9,2,FALSE)
A colleague's VLOOKUP has no FALSE at the end, and our menu isn't sorted. What's the risk?
Pick one answer.
What does =VLOOKUP(C2,$S$2:$T$9,3,FALSE) return?
Pick one answer.
FlashcardsIndex cardsFlashcards ⚡
Card 1 of 18Worth keeping
- XLOOKUP needs what to find, where to look and what to bring back.
- Lock the lookup ranges with $ before you fill down.
- #N/A means no match: check spelling and spaces, then add an if_not_found message.
- In old VLOOKUPs, check for FALSE at the end and a column number that fits the table.
Column N now shows profit on every line. The manager scrolls up and down: which lines were biggest? Just show me Ben's food. Sorting answers that in two clicks. But sort one column the wrong way, and every Total lands next to the wrong item, with no error.
Embed this practice on your site
Free for classrooms, blogs and study groups. Paste this into any page that accepts HTML.
Report a copyright problem with this lesson
Sources for this lesson (5)
Each fact in the lesson is marked with the number of the page it comes from.