Master XLOOKUP: The Ultimate Guide

Intermediate10 min readUpdated: July 2024

1. Introduction to XLOOKUP

XLOOKUP is Excel's modern replacement for VLOOKUP, HLOOKUP, and INDEX/MATCH combinations. Available in Excel 365 and Excel 2021, this powerful function simplifies data lookups while providing more flexibility and better performance.

Key Benefits:

  • Works in any direction (left, right, up, down)
  • Returns multiple values with a single formula
  • Handles missing values gracefully
  • No more counting columns!

2. XLOOKUP Syntax Explained

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

Parameters:

lookup_value
The value you want to find
lookup_array
The range where Excel searches for the lookup_value
return_array
The range containing the values to return
if_not_found (optional)
Value to return if no match is found (default: #N/A)
match_mode (optional)
  • 0: Exact match (default)
  • -1: Exact match or next smallest
  • 1: Exact match or next largest
  • 2: Wildcard match
search_mode (optional)
  • 1: Search first to last (default)
  • -1: Search last to first
  • 2: Binary search (ascending)
  • -2: Binary search (descending)

3. Practical Examples

Example 1: Basic Product Lookup

Find the price of a product from a price list:

=XLOOKUP("Apple", A2:A10, B2:B10)

This searches for "Apple" in column A and returns the corresponding price from column B.

Example 2: Employee Information Lookup

Find employee department with custom error message:

=XLOOKUP(E2, A2:A100, C2:C100, "Employee not found")

Returns the department from column C, or "Employee not found" if the ID doesn't exist.

Example 3: Two-way Lookup

Find sales data for specific product and month:

=XLOOKUP(Product, A2:A50, XLOOKUP(Month, B1:M1, B2:M50))

Nested XLOOKUP for row and column lookup - much simpler than INDEX/MATCH!

Try It: Experience XLOOKUP Power

Practice using XLOOKUP to see how it simplifies lookup operations compared to VLOOKUP.

Instructions:

  1. Employee data is in columns A-D (ID, Name, Department, Salary)
  2. Enter an employee ID in cell F2 (try 103)
  3. XLOOKUP Examples:
    • In G2: =XLOOKUP(F2,A2:A6,B2:B6) - Get employee name
    • In H2: =XLOOKUP(F2,A2:A6,C2:C6) - Get department
    • In I2: =XLOOKUP(F2,A2:A6,D2:D6) - Get salary
    • Or try in G2: =XLOOKUP(F2,A2:A6,B2:D6) - Get all three at once!
  4. XLOOKUP with error handling:
    • Try: =XLOOKUP(F2,A2:A6,B2:B6,"Not Found")
    • Then change F2 to 999 to see the custom error message
Loading simulator...

💡 XLOOKUP Advantages:

  • No need to count columns - just select the return range
  • Can return multiple values with one formula
  • Built-in error handling with custom messages
  • Works in any direction (left, right, up, down)

Formula Comparison

XLOOKUP (Modern)

=XLOOKUP(A2, B:B, D:D)

Simple, flexible, powerful

IDNameDeptSalary
101JohnSales$50K
102JaneIT$60K
✓ Returns $50K directly from any column

VLOOKUP (Traditional)

=VLOOKUP(A2, B:E, 4, FALSE)

Need to count columns, only looks right

IDNameDeptSalary
101JohnSales$50K
102JaneIT$60K
⚠ Must count to column 4, can't look left

4. XLOOKUP vs VLOOKUP

FeatureXLOOKUPVLOOKUP
Lookup directionAny directionOnly right
Column countingNot requiredRequired
Default if not foundCustomizable#N/A only
Multiple valuesYesNo
PerformanceFasterSlower

5. Advanced Techniques

Single Formula, Multiple Results

Formula: =XLOOKUP("101", A:A, B:D)

Returns entire row from columns B, C, D

A: IDB: NameC: DepartmentD: SalaryE: Location
101 ✓John SmithSales$55,000NYC
102Jane DoeMarketing$62,000LA
103Bob WilsonIT$70,000Chicago

Array Result:

John Smith
Sales
$55,000

All three values returned with one formula!

Return Multiple Columns

Get name, department, and salary with one formula:

Formula:

=XLOOKUP(A2, EmployeeID, EmployeeData)

How it works:

  • A2: Contains the employee ID to look up
  • EmployeeID: Named range or column with employee IDs
  • EmployeeData: Named range spanning multiple columns (B:D)

Result:

When EmployeeData spans columns B:D, this single formula returns all three values:

Name (B)Department (C)Salary (D)

Wildcard Pattern Matching

Visual Example

Formula: =XLOOKUP("*Pro*", A:A, B:B, "Not found", 2)

Finds any product containing "Pro" (match_mode = 2)

Product NamePrice
Surface Laptop$999
MacBook Pro ✓$1,299
iPad Air$599
Surface Pro$899

Wildcard Patterns:

"*Pro*" → Contains "Pro"
"Mac*" → Starts with "Mac"
"*book" → Ends with "book"
"???-???" → 3 chars, dash, 3 chars

Wildcard Searches

Find partial matches using wildcards:

Formula:

=XLOOKUP("*" & SearchTerm & "*", ProductNames, Prices, "Not found", 2)

Parameters:

  • "*" & SearchTerm & "*": Wraps search term with wildcards
  • ProductNames: Range to search in
  • Prices: Range to return values from
  • "Not found": Custom error message
  • 2: match_mode for wildcard matching

Wildcard Characters:

* = Any number of characters
? = Single character
*Pro* = Contains "Pro"
A?? = Starts with "A" + 2 chars

Last Occurrence

Find the most recent entry:

Formula:

=XLOOKUP(CustomerID, A:A, B:B, "No orders", 0, -1)

Parameters:

  • CustomerID: Value to look up
  • A:A: Column to search in
  • B:B: Column to return values from
  • "No orders": Custom error message
  • 0: match_mode for exact match
  • -1: search_mode for bottom-to-top search

Use Cases:

• Find latest customer order
• Get most recent transaction
• Retrieve current status
• Find last login date

6. Common Errors & Solutions

#NAME? Error

Cause: Excel doesn't recognize XLOOKUP (older version)

Solution: Upgrade to Excel 365 or Excel 2021, or use VLOOKUP/INDEX-MATCH

#VALUE! Error

Cause: Arrays have different sizes

Solution: Ensure lookup_array and return_array have the same number of rows/columns

#SPILL! Error

Cause: Result array is blocked by existing data

Solution: Clear cells where the formula needs to spill results

Practice Exercise

Ready to master XLOOKUP? Try this exercise:

  1. Create a product list with columns: Product ID, Name, Category, Price
  2. Use XLOOKUP to find a product's price by name
  3. Create a formula that returns both category and price with one XLOOKUP
  4. Add error handling for products that don't exist

Ready for the Next Step?

Continue your Excel journey with: Pivot Tables Mastery