Handling Misses With if_not_found
Return a friendly message when no match exists.
Handling Misses With if_not_found is a free Excel Formulas Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Excel Formulas Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
When a Lookup Finds Nothing
What happens when XLOOKUP cannot find the value you asked for? By default it returns the #N/A error.
That error is technically correct but looks ugly in a report and can break any formula that uses the result. XLOOKUP gives you a clean, built-in way to handle this.
=XLOOKUP("Mouse Pad", A2:A20, B2:B20)The if_not_found Argument
XLOOKUP has an optional fourth argument called if_not_found. Whatever you put there is returned when no match exists.
This is a major upgrade over VLOOKUP, which needed to be wrapped in IFERROR. With XLOOKUP the fallback is part of the same function.
=XLOOKUP(lookup_value, lookup_array, return_array, if_not_found)Returning a Friendly Message
The most common use is showing readable text instead of #N/A.
Here, if the product in D2 is not in the list, the cell shows "Not found" rather than an error code. Anyone reading the sheet instantly understands what happened.
=XLOOKUP(D2, A2:A20, B2:B20, "Not found")Returning Zero Instead
Sometimes a number is more useful than text, especially if the result feeds into a calculation.
You can return 0 when there is no match, so a later SUM or multiplication still works without producing its own error.
=XLOOKUP(D2, A2:A20, B2:B20, 0)Returning a Blank
To leave the cell visually empty when nothing matches, return an empty text string with two quotation marks.
This is handy for clean dashboards where blank cells are preferable to placeholder text. Note the cell is not truly empty - it contains an empty string - which matters if other formulas test for blanks.
=XLOOKUP(D2, A2:A20, B2:B20, "")A Worked Example
Suppose a sales rep types an order ID into D2 to look up the customer name. Order IDs are in column A, names in column C.
If they mistype the ID, the formula returns a clear instruction instead of a confusing error. The fallback message guides them to fix their input.
=XLOOKUP(D2, A2:A100, C2:C100, "Check the order ID")Fallback From Another Cell
The if_not_found value does not have to be typed text. It can point to another cell.
For instance, you might store a default region in G1 and return that whenever a specific lookup fails. This keeps the fallback editable without touching the formula.
=XLOOKUP(D2, A2:A20, B2:B20, G1)if_not_found vs IFERROR
You could still wrap XLOOKUP in IFERROR, but there is a subtle difference.
- if_not_found catches only the no-match case
- IFERROR hides every error, including ones caused by a genuine mistake in your formula
Using if_not_found is safer because real bugs stay visible instead of being masked.
=XLOOKUP(D2, A2:A20, B2:B20, "Not found")Chaining a Second Lookup
A neat trick: make the fallback of one XLOOKUP be another XLOOKUP.
Search a primary list first; if the item is missing, search a backup list. This is far cleaner than nested IFERRORs and reads almost like plain English.
=XLOOKUP(D2, A2:A20, B2:B20, XLOOKUP(D2, F2:F20, G2:G20, "Not found"))Combining With Calculations
When a lookup result feeds into math, a numeric fallback keeps everything working.
Here a missing price returns 0, so the multiplication by quantity in E2 still produces a number rather than an error spreading across your sheet.
=XLOOKUP(D2, A2:A20, B2:B20, 0) * E2Choosing the Right Fallback
Pick a fallback that matches the cell's purpose:
- Text like "Not found" for human-readable reports
0when the value is added or multiplied later- An empty string for clean visual layouts
- Another lookup for multi-source data
The fourth argument turns brittle lookups into polished, professional results.
=XLOOKUP(D2, A2:A20, B2:B20, "Not found")Quick Check
Test your understanding of the if_not_found argument.
Recap: Graceful Misses
You learned to handle lookups that find nothing:
- XLOOKUP returns
#N/Aby default when there is no match - The optional if_not_found argument supplies a clean fallback
- Use text, 0, a blank, a cell, or even a second XLOOKUP
- It only catches no-match cases, keeping real errors visible
Next you will search left and from the bottom of a list.
=XLOOKUP(D2, A2:A20, B2:B20, "Not found")Frequently asked questions
Is the “Handling Misses With if_not_found” lesson free?
Yes — the full text of “Handling Misses With if_not_found” is free to read here on the web, and the Excel Formulas Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Excel Formulas Academy course, upgrade to CoddyKit PRO.
What will I learn in “Handling Misses With if_not_found”?
Return a friendly message when no match exists. You practise Excel Formulas Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Excel Formulas Academy?
No prior experience is required. Excel Formulas Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Handling Misses With if_not_found” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Excel Formulas Academy lesson?
Yes. Every Excel Formulas Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The XLOOKUP Syntax
- Handling Misses With if_not_found
- Searching Left and From the Bottom
- Returning Whole Rows or Columns