How to Use the XLOOKUP Function in Microsoft Excel

For more than three decades, VLOOKUP was the default formula for searching and retrieving data across spreadsheets in Microsoft Excel. Despite its popularity, VLOOKUP suffered from notorious architectural limitations: it could only search from left to right, required tedious column counting, defaulted to approximate matching, and broke whenever columns were inserted or deleted.

To eliminate these frustrations, Microsoft introduced XLOOKUP in Microsoft 365 and Excel 2021. Designed as the ultimate successor to VLOOKUP, HLOOKUP, and complex INDEX/MATCH combinations, XLOOKUP can search in any direction (up, down, left, right), defaults to an exact match, handles missing values gracefully without nested IFERROR wrappers, and supports multi-condition lookups.

This comprehensive guide covers the anatomy of the XLOOKUP function, essential syntax rules, and practical step-by-step examples from basic queries to multi-criteria arrays.


Understanding the XLOOKUP Syntax

The XLOOKUP function has six arguments, though only the first three are mandatory:

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

Argument Breakdown

  • lookup_value (Required): The value you want to search for (e.g. a customer ID, product SKU, or cell reference).
  • lookup_array (Required): The single column or row where Excel searches for the lookup_value.
  • return_array (Required): The column, row, or table range from which to pull corresponding data.
  • [if_not_found] (Optional): The text or calculation returned if no match is found (replaces the need for IFERROR).
  • [match_mode] (Optional):
    • 0 (Default) – Exact match.
    • -1 – Exact match or next smaller item.
    • 1 – Exact match or next larger item.
    • 2 – Wildcard character match (*, ?).
  • [search_mode] (Optional):
    • 1 (Default) – Search from first item to last.
    • -1 – Search in reverse order (bottom to top).
    • 2 or -2 – High-speed binary search on sorted data.

Example 1: Basic Exact Match with Built-In Error Handling

Suppose you have an employee directory where employee IDs are in column A, full names are in column B, and department names are in column C. To find the department for employee ID "EMP-104" entered in cell F2:

=XLOOKUP(F2, A2:A100, C2:C100, "Employee Not Found")

Why This Beats VLOOKUP:

  • No need to remember column index numbers (e.g. 3).
  • No need to specify FALSE for an exact match; exact match is automatic.
  • If an invalid ID is typed, the formula cleanly displays “Employee Not Found” instead of an unsightly #N/A error.

Example 2: Looking Left (The Classic VLOOKUP Limitation)

One of the biggest historical flaws of VLOOKUP was its inability to retrieve values to the left of the lookup column without restructuring the table. XLOOKUP handles leftward searches effortlessly because the lookup array and return array are completely independent.

Suppose product prices reside in column A while product names reside in column B. To search by product name in cell E2 and retrieve the price from the left:

=XLOOKUP(E2, B2:B50, A2:A50, "Item Unavailable")

Excel inspects column B and immediately retrieves the corresponding figure from column A without altering your original table design.


Example 3: Returning Multiple Columns Simultaneously (Dynamic Spill)

Because XLOOKUP is a dynamic array formula, it can return an entire matrix of columns in a single formula without dragging.

If you want to pull an employee’s Name, Department, and Salary (columns B2:D20) using their ID in cell F2, enter:

=XLOOKUP(F2, A2:A20, B2:D20)

Excel automatically spills the retrieved data horizontally across three adjacent cells (e.g. G2, H2, and I2). If you update the employee ID, all three output fields refresh in unison.


Example 4: Multi-Criteria Lookup Using Boolean Logic

When searching for a record that must satisfy two or more conditions (for example, finding the price of a product for a specific region), you do not need helper columns or complex concatenation formulas.

To match Product in cell F2 and Region in cell G2:

=XLOOKUP(1, (A2:A100=F2) * (B2:B100=G2), C2:C100, "No Match Found")

Here, Excel multiplies the two condition arrays together: TRUE * TRUE evaluates to 1. The formula searches for the value 1 and returns the price from column C where both conditions are met.


Example 5: Reverse Search (Bottom-Up to Find the Latest Record)

In transaction logs, inventory receipts, or price history tables, the most recent update is usually added at the bottom of the worksheet. While standard lookup functions always return the first matching entry from the top, XLOOKUP can search from the bottom upward using the search_mode parameter.

=XLOOKUP(E2, A2:A1000, C2:C1000, "No Record", 0, -1)

By specifying -1 as the sixth argument, Excel scans upward from row 1000, immediately delivering the latest recorded entry for that item.


XLOOKUP vs VLOOKUP: Feature Comparison

Capability VLOOKUP XLOOKUP
Default Matching Approximate (requires FALSE) Exact Match (Safe by default)
Lookup Direction Left-to-right only Any direction (Left, Right, Up, Down)
Column Insertion Resilience Fragile (breaks hardcoded indexes) Robust (uses direct cell references)
Built-in Error Handling Requires nested IFERROR() Native [if_not_found] argument
Multi-Column Output Requires individual formulas per cell Dynamic Array Spill across cells
Reverse Search Not supported natively Supported via search_mode: -1

Troubleshooting Common XLOOKUP Errors

The #SPILL! Error

When returning multiple columns or rows, a #SPILL! error appears if adjacent cells in the output path already contain text, numbers, or formatting. Clear any obstructing cells to let the dynamic array expand cleanly.

The #VALUE! Error

Ensure that your lookup_array and return_array have identical row lengths (e.g. A2:A100 and C2:C100). If the lookup array has 99 rows while the return array has 100 rows, Excel throws a #VALUE! error due to mismatched dimensions.

Formula Appears as Text Instead of Evaluating

If Excel displays =XLOOKUP(...) literally as text, the cell was previously formatted as Text. Change the number format to General in the Home ribbon tab, click into the formula bar, and press Enter.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.