WorkbookLogic
FunctionDynamic ArrayadvancedXLOOKUPIF

XLOOKUP Function

By WorkbookLogic

The Excel XLOOKUP function finds a value in one range and returns the aligned value from another range, using exact matching by default.

ExcelLast reviewed Sep 11, 2026
xlookup-function-v1.0.0.xlsx
Excel XLOOKUP Function
XLOOKUP finds a key and returns the aligned value, with exact matching by default.
Source data, editableExamples
KeyItemPriceRegionExampleFormula syntaxResult
P-101Notebook$12.50SouthExact price=XLOOKUP("P-104",A12:A18,C12:C18)$24.50
P-102Marker Set$8.75NorthReturn leftward region=XLOOKUP("P-102",A12:A18,D12:D18)North
P-103Desk Tray$18.00EastLast duplicate status=XLOOKUP("T-7",A12:A18,D12:D18,"Not found",0,-1)Closed
P-104Task Lamp$24.50NorthCustom not found=XLOOKUP("P-999",A12:A18,C12:C18,"Not found")Not found
T-7Ticket$1.00Open
T-9Ticket$1.00Pending
T-7Ticket$1.00Closed
Reliability checks
Exact lookup returns the visible P-104 priceOK
Reverse search returns the final T-7 statusOK

Overview

The Excel XLOOKUP function searches one range for a key and returns the value in the corresponding position of another range. It defaults to exact matching, can return values from either side of the lookup range, and includes explicit controls for missing keys, duplicate keys, approximate matches, and search direction.

Quick reference

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

Returns: The aligned value or array from return_array, or the specified not-found value. (other)

Arguments:

  • lookup_value (required) — The value to find.
  • lookup_array (required) — The one-dimensional range or array to search.
  • return_array (required) — The aligned range or array containing the result.
  • if_not_found (optional) — A controlled result returned when no match exists.
  • match_mode (optional) — Controls exact, approximate, or wildcard matching; exact match is the default.
  • search_mode (optional) — Controls search direction or a sorted-data binary search.

The lookup value, one-dimensional lookup array, and aligned return array are required. Optional arguments provide a not-found result, matching mode, and search direction; exact matching is the default.

Common uses

  • Retrieve a price, category, owner, or status from an ID.
  • Return values located to the left of a lookup key.
  • Find the latest record when a key appears more than once.
  • Replace missing-key errors with a controlled message.

Calculations

XLOOKUP finds lookup_value inside lookup_array, identifies its relative position, and returns the item at that position from return_array. The lookup and return ranges must align, but the return range may sit to the left or right of the lookup range.

Exact matching is the default. If duplicates exist, the default search returns the first match; search_mode=-1 returns the last. The optional if_not_found value handles only the no-match case without concealing unrelated errors.

Binary search modes can improve performance on large sorted ranges, but they require the data to be sorted in the corresponding direction. Using them on unsorted data can return a plausible but incorrect result.

Function behavior

Situation

Behavior

Exact match

Default behavior when match_mode is omitted.

Lookup to either side

Supported because return_array is referenced independently.

Duplicate keys

First match by default; last match with search_mode=-1.

Missing key

Returns if_not_found when supplied; otherwise returns #N/A.

Wildcards

match_mode=2 enables *, ?, and ~.

Binary search

Requires correctly sorted lookup data.

Return array with multiple columns

Can spill more than one corresponding value.

Common errors

Misaligned lookup and return ranges

What happens:
The arrays do not describe corresponding positions, so the formula errors or returns the wrong record.

Better approach:
Use bounded ranges with the same lookup dimension.

Binary search on unsorted data

What happens:
The formula can return an invalid match without an obvious warning.

Better approach:
Use the default linear search unless the range is deliberately sorted and maintained for binary search.

Expecting the last duplicate by default

What happens:
The first occurrence is returned.

Better approach:
Set search_mode to -1 when the final occurrence is the intended record.

Example

Example 1 — Exact Price Lookup

=XLOOKUP("P-104",A12:A18,C12:C18)

On XLOOKUP Example, this returns $24.50, the price aligned with key P-104.

Example 2 — Return a Value from Another Direction

=XLOOKUP("P-102",A12:A18,D12:D18)

This returns North. XLOOKUP references the return range directly, so it does not rely on a hardcoded column index.

Example 3 — Return the Last Duplicate

=XLOOKUP("T-7",A12:A18,D12:D18,"Not found",0,-1)

The key T-7 appears twice. With exact matching and a last-to-first search, the formula returns the final status, Closed.

Example workbook

The workbook contains XLOOKUP Example and Notes. The example sheet provides seven editable synthetic records and four live formulas for exact lookup, a separate return column, reverse duplicate search, and custom not-found handling. Two checks confirm the price lookup and final duplicate status, and both display OK.

Key takeaway

Use XLOOKUP for an exact, direction-independent lookup; add an explicit not-found result and a reverse search only when the data requires them.