Back to Blog

Excel XLOOKUP: Modern Lookup for Any Data

Excel XLOOKUP: The Modern Lookup for Any Data (and Why You Should Use It!)

Are you still wrestling with VLOOKUP or HLOOKUP in Excel? Do you find yourself needing to look up data to the left of your lookup column, or struggling with exact matches versus approximate matches? If so, get ready to meet your new best friend: **XLOOKUP**.

Introduced in newer versions of Excel (Microsoft 365, Excel 2021), XLOOKUP is a powerful, flexible, and incredibly user-friendly function that revolutionizes how you retrieve data from tables and ranges. Think of it as the VLOOKUP and HLOOKUP you always wished existed, combined and then some!

At ExcelFormula Pro, we're all about making your data tasks easier. That's why we're thrilled to dive deep into XLOOKUP, explain its magic, and show you how it can transform your spreadsheets. Whether you're a beginner just starting with lookups or an intermediate user looking to upgrade your skills, this guide is for you.

Why XLOOKUP is a Game-Changer

For years, VLOOKUP has been the go-to for vertical lookups. However, it comes with several limitations:

  • Lookup Column Restriction: VLOOKUP can only search for a value in the *first* column of your lookup array. If your lookup value is in a column to the right, you'd need to rearrange your data or use more complex formulas.
  • Column Index Number: You have to manually count and enter the column number from which you want to return a value. This is prone to errors and breaks easily if columns are inserted or deleted.
  • Exact Match Default: VLOOKUP's default behavior is an *approximate* match, which can lead to unexpected results if you're not careful and are actually looking for an exact match.
  • No Leftward Lookup: As mentioned, it cannot look up data to the left of the lookup column.

HLOOKUP faces similar constraints for horizontal lookups.

XLOOKUP elegantly solves all these problems and introduces new capabilities, making it the superior choice for most lookup scenarios.

Understanding the XLOOKUP Syntax

The basic syntax for XLOOKUP is:

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

Let's break down each argument:

  • lookup_value: (Required) The value you want to search for. This can be a cell reference, a text string, or a number.
  • lookup_array: (Required) The range or array where you want to perform the lookup. This is the column (for vertical lookups) or row (for horizontal lookups) that contains your lookup_value.
  • return_array: (Required) The range or array from which to return the corresponding value. This range must be the same size as the lookup_array.
  • [if_not_found]: (Optional) What to return if the lookup_value is not found in the lookup_array. If omitted and the value isn't found, XLOOKUP returns a #N/A error. This is a huge improvement over VLOOKUP, where you'd typically wrap it in an IFERROR.
  • [match_mode]: (Optional) Specifies the type of match.
    • 0 (Default): Exact match.
    • -1: Exact match or the next smaller item.
    • 1: Exact match or the next larger item.
    • 2: Wildcard match (using *, ?, ~).
  • [search_mode]: (Optional) Specifies the search direction.
    • 1 (Default): Search from first to last.
    • -1: Search from last to first (useful for finding the last occurrence of a value).
    • 2: Binary search (requires the lookup_array to be sorted ascending).
    • -2: Binary search (requires the lookup_array to be sorted descending).

Practical XLOOKUP Examples

Let's illustrate XLOOKUP's power with some common scenarios. Imagine you have a sales data table like this:

Sheet1: Sales Data

Order ID Product Name Quantity Price Region
101 Laptop 2 1200 North
102 Mouse 5 25 South
103 Keyboard 3 75 East
104 Monitor 1 300 West
105 Laptop 1 1150 South

Example 1: Basic Exact Match Lookup (VLOOKUP Replacement)

You want to find the Price for a specific Order ID. Let's say you want to find the price for Order ID 103.

In a cell (e.g., E2), you'd enter:

=XLOOKUP(103, A2:A6, D2:D6)

Explanation:

  • 103 is our lookup_value.
  • A2:A6 is the lookup_array (Order IDs).
  • D2:D6 is the return_array (Prices).

This formula will return 75.

Example 2: Lookup to the Left (VLOOKUP's Biggest Weakness Solved!)

Now, let's say you have a list of Product Names and you want to find their corresponding Order ID. In VLOOKUP, this would be impossible without rearranging data. With XLOOKUP, it's simple.

If you want to find the Order ID for "Keyboard":

=XLOOKUP("Keyboard", B2:B6, A2:A6)

Explanation:

  • "Keyboard" is the lookup_value.
  • B2:B6 is the lookup_array (Product Names).
  • A2:A6 is the return_array (Order IDs).

This formula will return 103.

Example 3: Handling "Not Found" Errors Gracefully

What if you search for an Order ID that doesn't exist, like 106?

=XLOOKUP(106, A2:A6, D2:D6, "Order Not Found")

Explanation:

  • The first three arguments are the same.
  • "Order Not Found" is the if_not_found argument.

This formula will return "Order Not Found" instead of a #N/A error.

Example 4: Using Wildcards for Partial Matches

Suppose you want to find the Price for any product that *contains* the word "Laptop".

=XLOOKUP("*Laptop*", B2:B6, D2:D6, "Not Found", 2)

Explanation:

  • "*Laptop*" is the lookup_value. The asterisks are wildcards meaning "any characters before or after".
  • B2:B6

    Generate Excel Formulas with AI

    Need help creating formulas? Use ExcelFormula Pro to generate them instantly with AI!

    Try Free