To make XLOOKUP return a blank cell when it finds no match, use the formula =XLOOKUP(lookup_value, lookup_array, return_array, "") — the fourth argument, if_not_found, is set to an empty text string. This is the simplest and most direct way to avoid the default #N/A error.
How XLOOKUP Handles Missing Values by Default
In Microsoft Excel (Microsoft 365 and Excel 2021), XLOOKUP is the modern replacement for VLOOKUP and HLOOKUP. Its syntax is:
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
The if_not_found argument is optional. If you omit it and no match is found, XLOOKUP returns the #N/A error. That error is informative but often ugly in reports or dashboards. By supplying a value for if_not_found, you control exactly what appears instead. An empty string "" makes the cell appear blank, though technically it contains a formula that evaluates to a zero-length text string.
Basic Example: Returning Blank Instead of #N/A
Suppose you have a product list with item codes in column A (A2:A100) and prices in column B (B2:B100). You want to look up a code entered in cell D2 and return its price, or show a blank if the code doesn’t exist.
In cell E2, enter:
=XLOOKUP(D2, A2:A100, B2:B100, "")
If D2 contains “A-123” and that code is in A2:A100, the formula returns the corresponding price. If not, it returns an empty string, which displays as a blank cell. If you prefer to show a message, replace "" with "Not found" or any other text.
Why Use an Empty String Instead of IFERROR?
A common alternative is to wrap XLOOKUP in IFERROR: =IFERROR(XLOOKUP(D2, A2:A100, B2:B100), ""). That works, but it has a subtle downside: IFERROR catches all errors, not just the not-found case. If your lookup array contains a #DIV/0! or #VALUE! error in a matching cell, IFERROR would also blank that out, potentially hiding a real problem. Using the if_not_found argument is more precise because it only handles the no-match condition. Errors in the data still surface, which is usually what you want for data integrity.
Returning a Blank in Google Sheets
Google Sheets also has XLOOKUP (added in 2022). The syntax is identical, so =XLOOKUP(D2, A2:A100, B2:B100, "") works the same way. If you are using an older version of Excel that lacks XLOOKUP (pre-2021), use =IFERROR(VLOOKUP(D2, A2:B100, 2, FALSE), "") instead. In Google Sheets, you can also use =IFERROR(VLOOKUP(D2, A2:B100, 2, FALSE), "") as a fallback.
Common Pitfalls and How to Avoid Them
- Trailing spaces: If your lookup value has extra spaces, XLOOKUP won’t match. Use
=XLOOKUP(TRIM(D2), A2:A100, B2:B100, "")to trim both sides, or clean the data. - Numbers stored as text: A code like 12345 might be text in one column and a number in another. XLOOKUP treats them as different. Convert one using
VALUE()orTEXT(). - Case sensitivity: XLOOKUP is case-insensitive by default. If you need case-sensitive matching, set the fifth argument (match_mode) to 0 and use
EXACTin an array formula, or useXMATCHwith match_mode 0. - Blank cells in lookup array: If a cell in the lookup array is truly empty, XLOOKUP treats it as a blank and can match an empty lookup value. That’s rarely what you want; filter out blanks with
FILTERif necessary.
Using XLOOKUP with Multiple Criteria
Sometimes you need to look up based on two or more conditions. XLOOKUP can handle this by concatenating criteria. For example, with order IDs in A2:A100 and product codes in B2:B100, and returns in C2:C100, to find a match for both D2 (order) and E2 (product):
=XLOOKUP(D2&"|"&E2, A2:A100&"|"&B2:B100, C2:C100, "")
This creates an array of combined values in memory. Note that this is an array formula; in Excel 365 it works without special entry, but in older versions you’d need Ctrl+Shift+Enter. The "|" separator prevents accidental matches like “12” and “3” vs “1” and “23”.
Returning a Blank When Lookup Value Is Blank
If the lookup cell itself is empty, XLOOKUP will try to match a blank and may return a result if blanks exist in the lookup array. To avoid that, nest an IF check:
=IF(D2="", "", XLOOKUP(D2, A2:A100, B2:B100, ""))
This first checks if D2 is blank; if so, it returns a blank without performing the lookup. This is a common pattern in dashboards where users haven’t entered a value yet.
Frequently Asked Questions
Can I make XLOOKUP return a blank cell that is truly empty, not a formula?
No, a formula always leaves a result. If you want a truly empty cell, you’d need to use VBA to delete the formula or use a different approach like Power Query. For most purposes, an empty string displays as blank and works fine in further calculations (though it counts as text, so ISBLANK returns FALSE).
Does XLOOKUP return blank if the return cell is blank?
Yes, if the lookup finds a match but the corresponding return cell is empty, XLOOKUP returns 0 (zero) by default. To return a blank instead, use: =IF(XLOOKUP(D2, A2:A100, B2:B100, "")=0, "", XLOOKUP(D2, A2:A100, B2:B100, "")). Alternatively, use LET to avoid repeating the lookup: =LET(x, XLOOKUP(D2, A2:A100, B2:B100, ""), IF(x=0, "", x)). Note this treats actual zero values as blanks too; if your data can legitimately contain zero, use ISBLANK on the return range, but that requires a more complex formula.
What if I want to return a blank for #N/A but keep other errors?
Use the if_not_found argument as shown, because it only handles the no-match case. Other errors (like a value error in the lookup array) will still appear, which is usually desirable.
Is XLOOKUP available in Excel 2019 or older?
No, XLOOKUP was introduced in Excel 2021 and Microsoft 365. For older versions, use IFERROR(VLOOKUP(...), "") or IFERROR(INDEX/MATCH, "").
How do I return a blank if the lookup value is not found in Google Sheets?
Exactly the same: =XLOOKUP(D2, A2:A100, B2:B100, ""). If you’re using an older version of Sheets that doesn’t have XLOOKUP, use =IFERROR(VLOOKUP(D2, A2:B100, 2, FALSE), "").
Can I use a cell reference as the if_not_found argument?
Yes. For example, =XLOOKUP(D2, A2:A100, B2:B100, G1) will return whatever is in G1 (which could be a blank cell) when no match is found. This is useful if you want to change the fallback message without editing the formula.
Alternatives to XLOOKUP for Blank Returns
If you’re not on a version with XLOOKUP, or you need more flexibility, consider these:
- INDEX/MATCH:
=IF(ISNA(MATCH(D2, A2:A100, 0)), "", INDEX(B2:B100, MATCH(D2, A2:A100, 0)))— works in all Excel versions. - VLOOKUP with IFERROR:
=IFERROR(VLOOKUP(D2, A2:B100, 2, FALSE), "")— simple but catches all errors. - FILTER (Excel 365):
=IF(COUNTIF(A2:A100, D2)=0, "", FILTER(B2:B100, A2:A100=D2))— returns a blank if no match, but returns an array if multiple matches; wrap in@orINDEXfor a single result.
Each has its own behavior with duplicates and errors, so choose based on your data and version.
Performance and Best Practices
XLOOKUP is generally faster than VLOOKUP because it uses binary search by default. To keep it fast, avoid entire column references like A:A; use a defined range like A2:A1000. If you’re returning blanks frequently, it doesn’t affect performance. For large datasets, consider using XMATCH with INDEX for more control. Also, remember that XLOOKUP is case-insensitive; if you need case-sensitive, use EXACT in an array formula or use XMATCH with match_mode 0.
Related
- PySpark partitionBy Multiple Columns: How-To
- Shortcuts in a Computer? Explained Simply
- What Is an Enum in a Database? Definition & Use
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Subtotal Formula in Excel: SUM, SUBTOTAL, and MoreThe direct answer: there is no single “subtotal formula” in Excel. To add a simple subtotal, use =SUM()…
- SUMIF with Two Criteria in Excel (3 Ways)The direct answer: Excel has no single SUMIF function that accepts two criteria, but you can sum with…
- SQL String Replace Function: Syntax and ExamplesUse SQL’s REPLACE function to find every occurrence of one text value inside another and substitute different text:…
- NPV Formula Examples in Excel: Cash Flows ExplainedIn Excel, calculate net present value with =NPV(rate, future_cash_flows)+initial_cash_flow: enter the discount rate and future cash flows in…
- Clear Sort A to Z in Excel: Restore Your Data OrderTo undo an A-to-Z sort in Excel, press Ctrl+Z right away (Command+Z on Mac). If you have already…
- BigQuery SQL String Functions: The Essential GuideBigQuery SQL string functions are built-in operations that let you manipulate, extract, transform, and analyze text data directly…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.