ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Lookups
  3. XLOOKUP If Not Found: Show a Message Instead of #N/A

XLOOKUP If Not Found: Show a Message Instead of #N/A

By ExcelReady Team·Updated November 1, 2026·6 min read

The short answer

XLOOKUP has a built-in fourth argument, if_not_found, that replaces #N/A when no match exists. Write =XLOOKUP(F2,A2:A6,C2:C6,"Not found") to show a message. Use "" for a blank, 0 for zero, or another XLOOKUP as a backup search. It only catches missing values, so other errors still show, which helps you spot real mistakes.

Key takeaways

  • The fourth argument of XLOOKUP is if_not_found: what to return when there is no match.
  • Text needs double quotes ("Not found"); numbers and cell references don't.
  • Use "" for a blank cell or another XLOOKUP for a second place to look.
  • if_not_found only replaces #N/A from a missing match, unlike IFERROR, which hides every error.
  • To set a match mode without a message, leave the fourth argument empty: =XLOOKUP(F2,A2:A6,C2:C6,,-1).
On this page+
  1. How the if_not_found argument works
  2. How to show a message instead of #N/A
  3. Return a blank, a zero or a cell instead
  4. Use a second lookup as a backup
  5. if_not_found vs IFERROR and IFNA
  6. How to add a match mode without a message
  7. Common mistakes with XLOOKUP if not found
  8. Practise it

XLOOKUP if not found handling is built into the function: its fourth argument, if_not_found, tells Excel what to show when the value you are looking for isn't there. Instead of #N/A, you can show "Not found", a blank, a zero or the result of a second lookup. This guide covers each option, how it differs from IFERROR, and the small mistakes that stop it working.

XLOOKUP needs Excel 2021, Excel 2024, Microsoft 365 or Excel for the web. The beginner's guide to XLOOKUP covers the basics if you haven't used it yet.

How the if_not_found argument works#

The if_not_found argument is the fourth of XLOOKUP's six arguments, and it is optional. Here is the full syntax:

Excel formula
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

If you leave it out and there is no match, XLOOKUP returns #N/A. If you fill it in, XLOOKUP returns your value instead. All the examples use this price list:

ABC
1CodeProductPrice
2P-101Notebook4.50
3P-102Stapler12.00
4P-103Desk Tray18.75
5P-104Gel Pens6.20
6P-105Whiteboard45.00

How to show a message instead of #N/A#

Put the message in double quotes as the fourth argument. With P-109 in F2:

Excel formula
=XLOOKUP(F2,A2:A6,C2:C6,"Not found")

The result is Not found, because P-109 isn't in column A. With P-103 in F2, the same formula returns 18.75 as normal.

Keep the message short and specific. "Code not in price list" tells the reader more than "Error". A consistent message also makes the failures easy to count. If the results are in G2:G100, =COUNTIF(G2:G100,"Not found") tells you how many codes need checking, and a conditional formatting rule on the same text can colour those rows so they stand out. You can also keep the message in a cell, such as H1, and point to it with $H$1. Then you change the wording in one place for every formula.

Return a blank, a zero or a cell instead#

The fourth argument accepts any value, not just text. Choose based on what happens to the result next:

You wantFormulaNotes
A message=XLOOKUP(F2,A2:A6,C2:C6,"Not found")Text in double quotes
A blank-looking cell=XLOOKUP(F2,A2:A6,C2:C6,"")Two quotes with nothing between
Zero=XLOOKUP(F2,A2:A6,C2:C6,0)Numbers need no quotes
A value from a cell=XLOOKUP(F2,A2:A6,C2:C6,$H$1)Lock it with $ before copying

Zero is the safest choice when the result feeds a SUM or another calculation. A "" result is text, so =G2*2 on it gives #VALUE!, although SUM simply skips it.

Use a second lookup as a backup#

The fourth argument can be another formula, so XLOOKUP can search a second list when the first one has no match. Say current products are in A2:A6 and discontinued products are in E2:E4 with prices in F2:F4:

Excel formula
=XLOOKUP(F2,A2:A6,C2:C6,XLOOKUP(F2,E2:E4,F2:F4,"Not found"))

Excel searches the current list first. Only if that fails does it try the discontinued list, and only if both fail does it show "Not found". This is cleaner than nesting IFERROR around two VLOOKUPs. You can chain a third list the same way, but beyond two or three lists it is usually better to stack the lists into one table, so there is only one place to search and update.

if_not_found vs IFERROR and IFNA#

if_not_found only replaces the #N/A that comes from a missing match. Other errors still show. That is a good thing, because those errors point to real problems you need to fix.

MethodWhat it catchesWorks in
if_not_found argumentOnly "no match"Excel 2021, 2024, Microsoft 365
IFNAAny #N/AExcel 2013 and later
IFERROREvery error type, including #VALUE! and #REF!Excel 2007 and later

For example, if your lookup and return ranges are different sizes, XLOOKUP returns #VALUE!. if_not_found leaves that error visible, so you notice it. IFERROR would hide it behind your friendly message, and the sheet would look correct while being wrong. For older versions of Excel, the closest match is =IFNA(VLOOKUP(F2,A2:C6,3,FALSE),"Not found").

How to add a match mode without a message#

To use a match mode but keep the normal #N/A, leave the fourth argument empty with two commas. For example, =XLOOKUP(F2,A2:A6,C2:C6,,2) runs a wildcard search with no custom message. Count the commas carefully: the match mode must be the fifth argument. The guide to XLOOKUP wildcards and match modes explains each mode.

Common mistakes with XLOOKUP if not found#

These are the reasons your message doesn't appear, or appears when it shouldn't:

  1. Missing quotes around text. =XLOOKUP(F2,A2:A6,C2:C6,Not found) gives #NAME?. Write "Not found".
  2. Expecting the message for an empty result. If the code is found but its price cell is empty, XLOOKUP returns 0, not your message. The value was found; there was just nothing next to it.
  3. Hidden spaces or text numbers. If F2 holds "P-103 " with a trailing space, XLOOKUP shows your message even though P-103 is in the list. A message that appears too often is a sign of dirty data, as the guide to fixing XLOOKUP when it's not working explains.
  4. A blank lookup cell. If F2 is empty, you may get your message on every empty row. Wrap the formula to skip blanks: =IF(F2="","",XLOOKUP(F2,A2:A6,C2:C6,"Not found")).

When the value is on a different tab, the fourth argument works the same way; see XLOOKUP from another sheet or workbook. The XLOOKUP function guide is a quick reference for all six arguments.

Practise it#

Handling missing values cleanly is a small detail that job tests like to check. Practise XLOOKUP in a live spreadsheet: you type the formula, including the if_not_found message, and it checks your answer instantly. Then practise XLOOKUP match modes to see how the fourth and fifth arguments work together.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Product P-109 is not in the list. In G2, write an XLOOKUP that finds F2 in A2:A6, returns the price from C2:C6, and shows Not found when there is no match.

fx
ABCDEFGH
1
Code
Product
Price
Code
Price
2
P-101
Notebook
4.5
P-109
3
P-102
Stapler
12
4
P-103
Desk Tray
18.75
5
P-104
Gel Pens
6.2
6
P-105
Whiteboard
45
7
8
9

Tip: Add a fourth argument after the return range: the text Not found in double quotes.

Practise this in a lesson

LessonXLOOKUPLook up in any direction with XLOOKUP and show a friendly message when nothing matches.LessonXLOOKUP wildcards and match modesSearch partial names with XLOOKUP's wildcard mode, and place values into tiers with next-smaller and next-larger matches.Function guideXLOOKUPXLOOKUP explained with real examples: exact matches, looking left and custom not-found messages, plus a live exercise to try now.

Frequently asked questions

How do I return a blank instead of #N/A in XLOOKUP?

+

Put two double quotes as the fourth argument: =XLOOKUP(F2,A2:A6,C2:C6,""). The cell looks empty when there is no match.

What is the if_not_found argument in XLOOKUP?

+

It is the optional fourth argument. Whatever you put there is returned when XLOOKUP can't find the lookup value. If you leave it out, XLOOKUP returns #N/A.

Is if_not_found better than IFERROR?

+

Usually, yes. It is shorter and only handles missing matches. IFERROR also hides errors such as #VALUE! or #REF!, which can hide a broken formula.

Why does XLOOKUP return 0 instead of my not found message?

+

XLOOKUP did find the value, but the matching cell in the return range is empty. Excel shows an empty result as 0. The if_not_found message only appears when there is no match at all.

How do I do the same thing with VLOOKUP?

+

VLOOKUP has no if_not_found argument, so wrap it in IFNA: =IFNA(VLOOKUP(F2,A2:C6,3,FALSE),"Not found"). IFNA works in Excel 2013 and later.

Sources

  • XLOOKUP function - Microsoft Support
  • IFNA function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. How the if_not_found argument works
  2. How to show a message instead of #N/A
  3. Return a blank, a zero or a cell instead
  4. Use a second lookup as a backup
  5. if_not_found vs IFERROR and IFNA
  6. How to add a match mode without a message
  7. Common mistakes with XLOOKUP if not found
  8. Practise it

Keep reading

Lookups· 7 min read

XLOOKUP in Excel: Everything a Beginner Needs

XLOOKUP finds a value in one range and returns the matching item from another: =XLOOKUP(G2,B2:B9,A2:A9). It defaults to an exact match, can return a column on either side, and has a built-in if_not_found message instead of #N/A. It needs Excel 2021, Excel 2024 or Microsoft 365; it isn't in Excel 2019 or earlier.

Errors & fixes· 6 min read

XLOOKUP Not Working? Causes and Fixes

XLOOKUP fails for a few clear reasons. #NAME? means your Excel version doesn't have it (it needs Microsoft 365 or Excel 2021 or later). #N/A means the value wasn't found, often because of spaces or text vs numbers. #VALUE! means the lookup and return ranges are different sizes. Add a fourth argument such as "Not found" to handle missing values.

Lookups· 7 min read

Find the Last Match in Excel With XLOOKUP

To find the last match, set XLOOKUP's sixth argument, search_mode, to -1 so it searches from the bottom up: =XLOOKUP(F2,A2:A8,C2:C8,"Not found",0,-1). It returns the value from the last row where column A equals F2, such as the most recent price in a list sorted oldest first. XLOOKUP needs Excel 2021 or Microsoft 365.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free