How to return a default value when a lookup finds nothing
✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)Stop lookups showing #N/A when the value isn't in the table — show "Not found" (or 0) instead.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel (desktop) | =XLOOKUP(D2,A2:A4,B2:B4,"Not found") | XLOOKUP's 4th argument is the built-in not-found result. Older Excel: =IFERROR(VLOOKUP(D2,A2:B4,2,FALSE),"Not found"). |
| Google Sheets | =XLOOKUP(D2,A2:A4,B2:B4,"Not found") | Identical; the IFERROR+VLOOKUP form also works. |
| LibreOffice Calc | =XLOOKUP(D2,A2:A4,B2:B4,"Not found") | XLOOKUP needs LibreOffice 24.8+; earlier versions use IFERROR(VLOOKUP(...)). |
How it works
XLOOKUP takes the not-found result as its fourth argument — no error-wrapping needed. "pear" isn't in the fruit list, so the formula returns "Not found" instead of #N/A. The classic IFERROR(VLOOKUP(...)) pattern does the same in any version, but note IFERROR hides all errors (including typos in the range), while XLOOKUP's argument only handles the genuine not-found case.
Verified, not just documented
We ran =XLOOKUP(D2,A2:A4,B2:B4,"Not found") in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned Not found — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned Not found for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.
Functions used
XLOOKUP — see full Excel, Google Sheets & LibreOffice compatibility for each.
Related recipes
- How to use XLOOKUP
- How to look up the LAST matching value (not the first)
- How to look up a value with two criteria (multi-condition lookup)
- How to reference a cell on another sheet
- How to XLOOKUP from another sheet