Z XLOOKUP
Z XLOOKUP
XLOOKUP benefits
Notes
1. XLOOKUP can work with both vertical and horizontal arrays.
2. XLOOKUP will return #N/A if the lookup value is not found.
3. The lookup_array must have a dimension compatible with the return_array argument,
otherwise XLOOKUP will return #VALUE!
4. If XLOOKUP is used between workbooks, both workbooks must be open, otherwise XLOOKUP
will return #REF!.
XLOOKUP is a modern replacement for the VLOOKUP function. It is a flexible and versatile function that
can be used in a wide variety of situations.
XLOOKUP can find values in vertical or horizontal ranges, can perform approximate and exact matches,
and supports wildcards (* ?) for partial matches. In addition, XLOOKUP can search data starting from the
first value or the last value (see match type and search mode details below). Compared to older
functions like VLOOKUP, HLOOKUP, and LOOKUP, XLOOKUP offers several key advantages.
Note: Be careful if you supply an empty string (,"",) for not_found. If no match is found, XLOOKUP
will display nothing instead of #N/A. If you want to see the #N/A error when a match isn't
found, omit the argument entirely (,,).
Match mode/type
By default, XLOOKUP will perform an exact match. Match behavior is controlled by an optional
argument called match_type, which has the following options:
Search mode
By default, XLOOKUP will start matching from the first data value. Search behavior is controlled by
an optional argument called search_mode, which provides the following options:
Generic formula
=XLOOKUP(val1&val2&val3,rng1&rng2&rng3,results)
Summary
To use XLOOKUP with multiple criteria, you can concatenate lookup values
and lookup arrays directly in the formula. In the example shown, the formula in
H8 is:
=XLOOKUP(H5&H6&H7,B5:B14&C5:C14&D5:D14,E5:E14)
XLOOKUP returns $17.00, the price for a Large Red T-shirt.
Problems with VLOOKUP
Why bother introducing a new lookup function? VLOOKUP works just fine, right?
Well, there are a lot of problems with VLOOKUP that a beginner user might not be aware of.
When we’re not aware, things can go wrong and we might end up getting incorrect results.
• The VLOOKUP default is not an exact match. The 4th argument in VLOOKUP is optional,
but the default is to use an approximate match. This can often lead to incorrect results.
• VLOOKUP can only search from the first to last item and returns the first match.
• VLOOKUP can’t return results from the left, it can only return results to the right of the
lookup column. This means we sometimes end up needing to rearrange or add helper
columns to our data.
• VLOOKUP needs to reference an entire table. This means we are potentially referencing
a lot of cells unnecessarily and this can be very inefficient when recalculating a
workbook.
• The lookup column needs to be the first column in our referenced table. Again, this can
sometimes mean needing to awkwardly rearrange our data.
• Deleting or inserting columns can break VLOOKUP. The 3rd argument column reference
is often entered as a hard coded value. This means if we insert or delete a column the
relative position of the return column to the lookup column can change but the hard
coded value will not update. This can cause our VLOOKUP’s to return errors or
unintended results.
• Approximate match
can only return the next smallest item, and
needs data sorted in ascending order. Unsorted data in this situation can lead to
incorrect results.
You canNOT use XLookup to return results of multiple matches for multiple occurrences of a lookup_value.
Below is one possible solution: