Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

XLOOKUP Errors: Common Causes & Fixes

· 6 min read · Home Tech

In this article
  1. What Is XLOOKUP and Why Does It Error?
  2. The Most Common XLOOKUP Errors and Their Meanings
  3. Fix #N/A: Lookup Value Not Found
  4. Fix #VALUE! and #REF!: Range Size Mismatch
  5. Fix #NAME? and #SPILL!: Version and Output Issues
  6. Common Data Formatting Issues
  7. How to Choose the Right Arguments
  8. Frequently Asked Questions

XLOOKUP errors usually come from a handful of predictable causes—wrong lookup values, mismatched ranges, missing exact matches, or data formatting issues—and each has a straightforward fix. Below are the most common XLOOKUP error messages, why they appear, and the exact steps to resolve them.

What Is XLOOKUP and Why Does It Error?

XLOOKUP is a modern Excel function that searches for a value in one column or row and returns a matching value from another column or row. It replaced older functions like VLOOKUP and HLOOKUP because it can look to the left, return multiple columns, and handle missing values with a custom message. However, its flexibility also introduces new ways to make mistakes. Most errors fall into three categories: the lookup value isn't found, the ranges are misaligned, or the data itself is inconsistent (like numbers stored as text). Understanding which category your error falls into is the first step to fixing it.

The Most Common XLOOKUP Errors and Their Meanings

  • #N/A – The lookup value is not found in the lookup array. This is the most frequent error.
  • #VALUE! – The lookup or return array is not a single row or column, or the arrays have different sizes.
  • #REF! – The return array is not the same size as the lookup array, or a cell reference is invalid.
  • #NAME? – The function name is misspelled, or you're using an older Excel version that doesn't support XLOOKUP.
  • #SPILL! – The formula returns multiple results but there isn't enough space to display them.

Each error has a distinct cause, but the fixes often overlap. The sections below walk through the most common scenarios.

Fix #N/A: Lookup Value Not Found

The #N/A error means Excel couldn't find your lookup value in the lookup array. This happens for several reasons:

  • Typo or extra spaces: The lookup value contains a space or non-printing character that isn't in the data.
  • Data type mismatch: The lookup value is a number, but the lookup array contains numbers stored as text (or vice versa).
  • Wrong lookup array: You selected the wrong column or row to search.

How to fix:

  1. Check the lookup value for leading/trailing spaces using =LEN(A1) vs. =LEN(TRIM(A1)).
  2. Convert text numbers to real numbers: select the column, click the warning icon, and choose “Convert to Number.”
  3. Use the match_mode argument. Set it to 0 for exact match (default) or -1 for exact or next smaller. If you need a wildcard match, use 2.
  4. If the value might not exist, add the if_not_found argument: =XLOOKUP(A1, B:B, C:C, "Not found").

Fix #VALUE! and #REF!: Range Size Mismatch

XLOOKUP requires that the lookup array and return array be the same size (same number of rows or columns). If you accidentally select a different number of rows, you'll get #VALUE! or #REF!. For example, if your lookup array is B2:B100 and your return array is C2:C99, XLOOKUP will fail.

How to fix:

  1. Ensure both arrays have the same number of cells. The easiest way is to use entire columns: =XLOOKUP(A2, B:B, C:C).
  2. If you use specific ranges, double-check the row numbers. For instance, =XLOOKUP(A2, B2:B100, C2:C100) is correct; B2:B100 and C2:C50 is not.
  3. For horizontal lookups, both arrays must be the same width (e.g., B1:Z1 and B2:Z2).
  4. Fix #NAME? and #SPILL!: Version and Output Issues

    #NAME? usually means your Excel version doesn't support XLOOKUP (it's available in Excel 2021, Excel 365, and Excel for the web). Alternatively, you might have a typo in the function name. #SPILL! occurs when XLOOKUP returns multiple values (e.g., when the lookup value appears multiple times and you didn't set match_mode to exact) and there isn't enough space below or to the right of the formula cell.

    How to fix:

    • For #NAME?, update Excel or use INDEX/MATCH as a fallback.
    • For #SPILL!, clear the cells that block the spill range, or use a single result by ensuring your lookup value is unique and match_mode is 0.

    Common Data Formatting Issues

    Even if your formula is correct, data formatting can cause errors. Here are the top culprits:

    • Numbers stored as text: You can't match a number to text. Use the VALUE() function or Excel's “Convert to Number” feature.
    • Inconsistent date formats: Dates are stored as serial numbers; if one column is text and the other is a date, XLOOKUP fails. Ensure both are true dates.
    • Hidden characters: Imported data may contain non-breaking spaces or line breaks. Use =CLEAN(TRIM(A1)) to remove them.

    How to Choose the Right Arguments

    XLOOKUP has six arguments, but only the first three are required:

    1. lookup_value – what you search for.
    2. lookup_array – where to search.
    3. return_array – where to get the result from.
    4. if_not_found – custom message when no match.
    5. match_mode – 0 exact, -1 exact or next smaller, 1 exact or next larger, 2 wildcard.
    6. search_mode – 1 first-to-last, -1 last-to-first, 2 binary (requires sorted data), -2 binary (reverse).

    Using the wrong match_mode is a common source of unexpected results. For example, if you use 1 (exact or next larger) and your lookup value is 10, but the data has 9 and 11, you'll get 11 instead of an error. Always set match_mode to 0 unless you specifically need approximate matches.

    Frequently Asked Questions

    Why does XLOOKUP return #N/A even though the value appears in the data?

    This usually means a data type mismatch or hidden spaces. Check if the lookup value is a number and the lookup array contains text (or vice versa). Use =ISNUMBER(A1) to test. Also, use =TRIM(A1) on both the lookup value and the array to remove extra spaces.

    Can XLOOKUP replace VLOOKUP and INDEX/MATCH?

    Yes, in most cases. XLOOKUP is more flexible because it can look left, return multiple columns, and has built-in error handling. However, if you need to share the workbook with users on older Excel versions, you'll need to stick with VLOOKUP or INDEX/MATCH.

    How do I use XLOOKUP to return multiple columns?

    Instead of a single return array, you can specify multiple columns, e.g., =XLOOKUP(A2, B:B, C:D). This returns two columns, but because it's a dynamic array, it will spill into adjacent cells. Ensure there's enough space and no other data blocks the spill.

    What does the #SPILL! error mean and how do I fix it?

    #SPILL! means the formula wants to return more than one value, but the cells below or to the right are not empty. Clear those cells, or if you only want one result, make sure your lookup value is unique and match_mode is 0.

    Is XLOOKUP case-sensitive?

    By default, XLOOKUP is not case-sensitive. If you need case-sensitive matching, you must use EXACT with MATCH or use a helper column. For example, =XLOOKUP(1, --EXACT(A2, B:B), C:C).

    Why does XLOOKUP return a wrong value instead of an error?

    This often happens when you use match_mode of 1 or -1 (approximate match). If your data isn't sorted correctly, you'll get incorrect results. For exact matches, always use 0. Also, check that your lookup array doesn't contain duplicates—XLOOKUP returns the first match by default.