Today we're diving into one of Excel's most powerful and versatile functions: XLOOKUP. If you’ve ever found yourself tangled in a web of VLOOKUP or HLOOKUP formulas, XLOOKUP is here to save the day!
XLOOKUP is the Swiss Army knife of lookup functions in Excel. Unlike its predecessors, VLOOKUP and HLOOKUP, XLOOKUP can search for values both vertically and horizontally, making it incredibly flexible. It’s designed to simplify your data analysis and make your spreadsheets more efficient.
XLOOKUP addresses many of the limitations of VLOOKUP and HLOOKUP. It can:
The XLOOKUP function searches a range or an array, and then returns the item corresponding to the first match it finds. If no match exists, then XLOOKUP can return the closest (approximate) match.
XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
| Argument | Description |
|---|---|
lookup_value Required* | The value to search for |
lookup_array Required | The array or range to search |
return_array Required | The array or range to return |
[if_not_found] Optional | Where a valid match is not found, return the [if_not_found] text you supply. If a valid match is not found, and [if_not_found] is missing,#N/Ais returned. |
[match_mode] Optional | Specify the match type: 0 - Exact match. If none found, return #N/A. This is the default. -1 - Exact match. If none found, return the next smaller item. 1 - Exact match. If none found, return the next larger item. 2 - A wildcard match where *, ?, and ~ havespecial meaning. |
[search_mode] Optional | Specify the search mode to use: 1 - Perform a search starting at the first item. This is the default. -1 - Perform a reverse search starting at the last item. 2 - Perform a binary search that relies on lookup_array being sorted inascendingorder. If not sorted, invalid results will be returned. -2 - Perform a binary search that relies on lookup_array being sorted indescendingorder. If not sorted, invalid results will be returned. |
Use XLOOKUP to look up a country name in a range, and then return its telephone country code. It includes the lookup_value (cell F2), lookup_array (range B2:B11), and return_array (range D2:D11) arguments. It doesn't include the match_mode argument, as XLOOKUP produces an exact match by default.
Use a nested XLOOKUP function to perform both a vertical and horizontal match. It first looks for Gross Profit in column B, then looks for Qtr1 in the top row of the table (range C5:F5), and finally returns the value at the intersection of the two. This is similar to using the INDEX and MATCH functions together.
XLOOKUP is a game-changer for anyone who works with data in Excel. Its flexibility and power make it an essential tool for simplifying complex lookup tasks. Whether you’re managing inventory, analyzing financial data, or providing customer support, XLOOKUP can help you work smarter, not harder.
So, next time you find yourself wrestling with lookup functions, give XLOOKUP a try. You’ll wonder how you ever managed without it!
Links
- https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-88eae8bf5929
