Category: FUNCTION | Updated: 2026-11-20

How to Use the XLOOKUP Function in Google Sheets | Next-Gen Lookup in Any Direction

How to Use the XLOOKUP Function

The XLOOKUP function is a modern replacement for VLOOKUP and HLOOKUP that eliminates their limitations. It lets you look up values to the left and specify a fallback value when no match is found cleanly in a single formula.

Syntax

=XLOOKUP(search_key, lookup_range, result_range, [missing_value], [match_mode], [search_mode])
  • search_key: The value or cell reference to search for (required).
  • lookup_range: The single-column (or single-row) range to search for search_key (required).
  • result_range: The range containing the value(s) to return (required).
  • missing_value: The value to return if no match is found, such as "Not Found" (optional; returns #N/A if omitted).
  • match_mode: 0 (exact match, default), -1 (exact match or next smaller item), 1 (exact match or next larger item), or 2 (wildcard match) (optional).
  • search_mode: 1 (search from first to last, default) or -1 (reverse search from last to first), etc. (optional).

Table Example

Here is an example of retrieving the "Product Name" on the left from Columns D–E (where "Product Name" is on the left and "Product Code" is on the right) based on the "Order Code" in Column A.

Row Column A (Order Code) Column B (Product Name) Column C Column D (Master Product Name) Column E (Product Code)
1 Order Code Product Name Master Product Name Product Code
2 C-102 =XLOOKUP(A2, $E$2:$E$4, $D$2:$D$4, "Unregistered") Coffee Beans 200g C-101
3 C-999 =XLOOKUP(A3, $E$2:$E$4, $D$2:$D$4, "Unregistered") Black Tea Bags C-102
4 C-101 =XLOOKUP(A4, $E$2:$E$4, $D$2:$D$4, "Unregistered") Matcha Powder C-103
  • Row 2 formula: =XLOOKUP(A2, $E$2:$E$4, $D$2:$D$4, "Unregistered") → Result: Black Tea Bags
  • Row 3 formula: =XLOOKUP(A3, $E$2:$E$4, $D$2:$D$4, "Unregistered") → Not found, so result: Unregistered

Common Errors and Notes

  • Mismatched sizes between lookup_range and result_range (#VALUE! error): If lookup_range (e.g., $E$2:$E$4) and result_range (e.g., $D$2:$D$10) have different numbers of rows (or columns), a #VALUE! error occurs. Always align the start and end rows.
  • Spill collision when returning multiple columns (#REF! error): When returning multiple columns, if any cell to the right where the results need to spill already contains text or a formula, a #REF! error (cannot overwrite) occurs.
  • Remember to set match_mode for wildcards: If you want to perform a partial match using wildcards (* or ?), be sure to set the 5th argument (match_mode) to 2.

Frequently Asked Questions

Q. What advantages does XLOOKUP have over VLOOKUP?

A. It can return values from columns to the left of the lookup column, references do not break when columns are inserted or deleted, exact match is the default, and you can specify a custom message for missing values directly in the 4th argument.

Q. Can XLOOKUP return data from multiple columns at once?

A. Yes. If you specify multiple columns in result_range such as "C2:E10", the matching row's values across all those columns will automatically spill horizontally.