XLOOKUP is Excel's modern, flexible lookup function that searches a range for a value and returns a corresponding value from another range. It replaces VLOOKUP, HLOOKUP, and INDEX/MATCH combinations with a simpler, more powerful syntax. XLOOKUP works in any direction and includes built-in error handling.
=XLOOKUP(lookup_value, lookup_array, return_array, if_not_found, match_mode, search_mode)The value to search for. Can be a number, text, logical value, or cell reference.
The array or range to search. This is the range containing the values to find.
The array or range to return values from. Can be same or different range than lookup_array.
Value to return if lookup_value is not found. If omitted, returns #N/A error.
Match type: 0=exact (default), -1=exact or next smaller, 1=exact or next larger, 2=wildcard match.
Search direction: 1=first to last (default), -1=last to first, 2=binary ascending, -2=binary descending.
Value from return_array corresponding to lookup_value position in lookup_array
Description: Searches for a value and returns a corresponding value from another range with flexible matching and search options
Simple lookup with default exact match
Simplest XLOOKUP. Searches A1:A5 for "John" and returns corresponding value from B1:B5. Much simpler than VLOOKUP!
Master the fundamentals of Excel XLOOKUP function
XLOOKUP is Excel's modern replacement for VLOOKUP, HLOOKUP, and INDEX/MATCH combinations. Introduced in Excel 365, XLOOKUP provides a simpler syntax, works in any direction, includes built-in error handling, and offers advanced matching options. It's the recommended lookup function for new projects.
Works left, right, up, or down
Easier than VLOOKUP/HLOOKUP
Optional default value parameter
Match modes and search directions
Function-specific parameters
Function-specific return type
Replace VLOOKUP/HLOOKUP with simpler syntax
Look up values to the left of lookup column
Exact, approximate, or wildcard matching
Built-in default values for missing data
Exact matching required
Returns numeric position
Handles missing text gracefully
=XLOOKUP(lookup_value, lookup_array, return_array, if_not_found, match_mode, search_mode)Value to search for
Range to search in
Range to return value from
Default value if not found
0=exact, -1/1=approximate, 2=wildcard
1=first-last, -1=last-first, 2/-2=binary
Value from return_array or if_not_found if not found
Description: Modern lookup function that works in any direction with flexible matching
Simple lookup
Simplest XLOOKUP syntax
Using XLOOKUP in VBA (Excel 365+)
Sub XLOOKUPExample()
' Note: XLOOKUP requires Excel 365 or later
' Method 1: Basic XLOOKUP
Dim result As Variant
result = Application.WorksheetFunction.XLookup("John", Range("A1:A5"), Range("B1:B5"))
Range("C1").Value = result
' Method 2: With default value
result = Application.WorksheetFunction.XLookup("NotFound", _
Range("A1:A5"), Range("B1:B5"), "Not Found")
Range("C2").Value = result
' Method 3: Left lookup
result = Application.WorksheetFunction.XLookup("John", _
Range("B1:B5"), Range("A1:A5"))
Range("C3").Value = result
' Method 4: Reverse search (last to first)
result = Application.WorksheetFunction.XLookup("John", _
Range("A1:A5"), Range("B1:B5"), , , -1)
Range("C4").Value = result
' Method 5: Approximate match
result = Application.WorksheetFunction.XLookup(85, _
Range("A1:A5"), Range("B1:B5"), , -1)
Range("C5").Value = result
' Method 6: Error handling
On Error Resume Next
result = Application.WorksheetFunction.XLookup("X", _
Range("A1:A5"), Range("B1:B5"))
If Err.Number <> 0 Then
Range("C6").Value = "Error: " & Err.Description
Err.Clear
Else
Range("C6").Value = result
End If
On Error GoTo 0
End SubModern replacement with simpler syntax
Look up values to the left
Built-in default values
Find last occurrence
Function not recognized or #NAME? error
Check Excel version - XLOOKUP requires 365/2021+Solution: XLOOKUP requires Excel 365 or Excel 2021 or later. For earlier versions, use VLOOKUP, HLOOKUP, or INDEX/MATCH instead.
Lookup value not found
=XLOOKUP(Value, Lookup, Return, "Not Found")Solution: Verify lookup value exists in lookup_array. Use if_not_found parameter to provide default value: XLOOKUP(..., "Not Found"). Check for typos, case sensitivity, and data types.
XLOOKUP returns unexpected value
=XLOOKUP(Value, Lookup, Return, , 0)Solution: Verify lookup_array and return_array ranges are correct and aligned. Check match_mode - use 0 for exact matches unless you need approximate.
Slow performance with large datasets
=XLOOKUP(Value, Lookup, Return, , 0, 2)Solution: Limit lookup_array and return_array to necessary data only. For sorted data, consider using binary search mode (2 or -2) for better performance.