Google Sheets XLOOKUP: Syntax, Examples & Fixes

How-to basics · Updated November 23, 2026

Google Sheets XLOOKUP function finds a value in a column or row and returns a matching value from another column or row, with the syntax XLOOKUP(search_key, lookup_range, result_range, missing_value, [match_mode], [search_mode]). It works like Excel’s XLOOKUP but has its own argument order and defaults, and it’s available to all Google Sheets users. Below is a complete guide to using it, including examples, common errors, and how it compares to VLOOKUP.

What Is XLOOKUP and Why Use It?

XLOOKUP is a modern lookup function that searches for a key in a range and returns a value from a corresponding position in another range. It was introduced to Google Sheets in 2022 and is now a standard function. Unlike VLOOKUP, XLOOKUP can look to the left or right, return multiple values, and handle missing matches gracefully. It also doesn’t require the lookup column to be the first column of a table.

For example, if you have product IDs in column A and prices in column B, you can use XLOOKUP to find the price for a given ID. The function returns the first exact match by default, or you can set match mode for approximate matches.

XLOOKUP Syntax and Arguments

The full syntax is:

XLOOKUP(search_key, lookup_range, result_range, missing_value, [match_mode], [search_mode])
  • search_key – the value to look for (can be a cell reference or a literal).
  • lookup_range – the range to search in (one row or one column).
  • result_range – the range from which to return the result (same size as lookup_range).
  • missing_value – optional; what to return if no match is found. Defaults to #N/A.
  • match_mode – optional; 0 for exact match (default), 1 for exact or next larger, -1 for exact or next smaller, 2 for wildcard match.
  • search_mode – optional; 1 for search from first to last (default), -1 for last to first, 2 for binary search ascending, -2 for binary search descending.

Note: The missing_value argument is the 4th argument, not the 3rd as in Excel. In Excel, the 3rd argument is if_not_found. So the argument order differs between the two applications.

Basic XLOOKUP Example with Step-by-Step

Assume you have a sheet with employee names in A2:A10 and their departments in B2:B10. You want to find the department of the employee in D2.

  1. In cell E2, type: =XLOOKUP(D2, A2:A10, B2:B10)
  2. Press Enter. The function searches for the name in D2 within A2:A10 and returns the corresponding department from B2:B10.

If the name is not found, it returns #N/A. To show a friendly message, add the 4th argument: =XLOOKUP(D2, A2:A10, B2:B10, "Not found").

XLOOKUP vs VLOOKUP vs INDEX/MATCH

XLOOKUP replaces most uses of VLOOKUP and INDEX/MATCH. Here’s a quick comparison:

  • VLOOKUP – can only look to the right of the lookup column, requires the lookup column to be the first column in the range, and defaults to approximate match. It can’t return a value to the left.
  • INDEX/MATCH – more flexible but requires two functions and more complex syntax. XLOOKUP does the same with one function.
  • XLOOKUP – can look left or right, defaults to exact match, handles missing values with a custom message, and supports wildcards and binary search.

For most new spreadsheets, XLOOKUP is the recommended choice.

Common Errors and How to Fix Them

Here are typical problems you might encounter:

  • #N/A – No match found. Check for typos, extra spaces, or number stored as text. Use the missing_value argument to show a custom message.
  • #VALUE! – The lookup and result ranges have different sizes. Ensure they are the same number of rows or columns.
  • #REF! – The ranges are not valid, often because a column was deleted. Check the range references.
  • Wrong results with approximate match – If you need exact match, set match_mode to 0. Default is 0, but if you accidentally use 1 or -1, you might get a close match.

Using Match Mode and Search Mode

Match mode controls what counts as a match:

  • 0 – exact match (default).
  • 1 – exact match or next larger value (for sorted data).
  • -1 – exact match or next smaller value (for sorted data).
  • 2 – wildcard match: use * for any sequence, ? for any single character, and ~ to escape wildcards.

Search mode controls the search direction:

  • 1 – search from first to last (default).
  • -1 – search from last to first (useful for finding the last occurrence).
  • 2 or -2 – binary search, which is faster on large sorted ranges but requires sorted data.

Example: To find the last sale amount for a product in a list sorted by date, use =XLOOKUP("Product A", A2:A100, C2:C100, "No sale", 0, -1).

XLOOKUP with Wildcards and Multiple Results

Wildcards are handy for partial matches. For instance, to find a product that starts with “Pro”, use =XLOOKUP("Pro*", A2:A10, B2:B10, "No match", 2). The asterisk matches any sequence of characters.

XLOOKUP can also return multiple results if you use an array formula. For example, to return both the department and salary for an employee, you can use =XLOOKUP(D2, A2:A10, B2:C10) – this returns an array of two values, which spill into adjacent cells if you have enough space. In Google Sheets, this works automatically with dynamic arrays.

Frequently Asked Questions

Is XLOOKUP available in all Google Sheets accounts?

Yes, XLOOKUP is available to all Google Sheets users, including free personal accounts and Workspace accounts. It works in the web browser, Android, and iOS apps.

How is Google Sheets XLOOKUP different from Excel’s XLOOKUP?

The syntax is similar but not identical. In Excel, the 3rd argument is if_not_found, while in Google Sheets it’s the 4th argument. Also, Excel’s XLOOKUP has a match_mode and search_mode but the default for missing is #N/A, same as Sheets. The main difference is the argument order and that Sheets’ XLOOKUP is not available in older versions of Excel.

Can XLOOKUP return a value from a column to the left of the lookup column?

Yes, unlike VLOOKUP, XLOOKUP can return values from any column, including those to the left. Just set the result_range to that column.

How do I use XLOOKUP to find the last match in a column?

Set the search_mode to -1. For example: =XLOOKUP("Apple", A2:A100, B2:B100, "Not found", 0, -1) returns the value from the last row where “Apple” appears in A2:A100.

Why is my XLOOKUP returning #N/A even though the value exists?

Check for leading/trailing spaces, different data types (text vs number), or non-printable characters. Use =TRIM() on the lookup range or use wildcard match mode to be more flexible.

Can I use XLOOKUP with a range that spans multiple rows and columns?

Yes, but the lookup range must be a single row or a single column. The result range must be the same size. If you need a two-dimensional lookup, consider using INDEX/MATCH or FILTER instead.

Alternatives to XLOOKUP in Google Sheets

If XLOOKUP doesn’t fit your need, consider these:

  • VLOOKUP – for simple exact/approximate lookups to the right, especially if you’re sharing with Excel users who don’t have XLOOKUP.
  • INDEX/MATCH – for two-way lookups or when you need more control.
  • FILTER – to return multiple matching values as a list.
  • QUERY – for complex lookups with SQL-like syntax.

Each has its strengths, but XLOOKUP is the most straightforward for most single-value lookups.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.