Excel Practice Test

โ–ถ

XLOOKUP Excel: How It Works and When to Use It

XLOOKUP is a lookup function in Microsoft Excel that finds a value in one range and returns a corresponding value from another range. Microsoft introduced it in 2019 as a direct replacement for VLOOKUP, HLOOKUP, and INDEX/MATCH. It does what those functions do โ€” with a simpler syntax and fewer limitations that have frustrated Excel users for decades.

The biggest practical difference is that XLOOKUP isn't constrained to searching the leftmost column of a range. With VLOOKUP, your lookup column had to be the first column in your table, which forced users to restructure data or rely on workarounds. XLOOKUP separates the search range from the return range entirely, so you can look up in any column and return from any other column regardless of their positions relative to each other.

XLOOKUP also handles the "not found" case natively. Instead of returning a cryptic #N/A error when no match exists, you can specify a fallback value โ€” a message like "Not found", a zero, or a blank โ€” directly in the function. This eliminates the nested IFERROR wrapping that VLOOKUP users learned as a reflex.

The function is available in Excel 365, Excel 2021, and Excel for the web. It isn't available in Excel 2019, Excel 2016, or earlier versions. If you're sharing workbooks with colleagues on older Excel versions, XLOOKUP will display as a #NAME? error on their end, which matters for compatibility decisions. If your organization standardizes on Excel 365, XLOOKUP is safe to use for everything. Brushing up on the full range of Excel formulas guide alongside XLOOKUP gives you a complete picture of what the modern function library offers.

One thing that surprises users new to XLOOKUP is how much it changes formula maintenance. In large workbooks with many lookup formulas, the traditional VLOOKUP approach creates a fragile dependency on column position. Inserting a column anywhere in the referenced range shifts column numbers without warning, breaking formulas silently โ€” you only discover the breakage when results look wrong.

XLOOKUP's direct column referencing eliminates this fragility entirely. The return_array always points to the specific column you selected, regardless of what happens to neighboring columns. This reliability becomes increasingly valuable as workbooks grow in complexity and more people make changes to the underlying data structure over time.

XLOOKUP is also the first Microsoft lookup function to support spilled results natively. When you ask for a multi-column return, Excel fills adjacent cells automatically without requiring Ctrl+Shift+Enter array entry. This integration with Excel's dynamic array engine means XLOOKUP formulas participate in spill range operations โ€” you can reference the entire spill output using the # operator, which further simplifies downstream formula work.

XLOOKUP Quick Reference
  • Syntax: =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
  • Required arguments: lookup_value, lookup_array, return_array
  • Optional arguments: if_not_found, match_mode, search_mode
  • Available in: Excel 365, Excel 2021, Excel Online
  • Not available in: Excel 2019, Excel 2016, and earlier
  • Default match mode: Exact match (0)
  • Default search mode: First-to-last (1)

How to Use XLOOKUP: Step by Step

๐Ÿ“‹

Determine the value you're searching for โ€” this is your lookup_value. It can be a cell reference (like A2), a typed value in quotes ("Smith"), or a number. Most commonly it's a cell reference so you can copy the formula down a column.

๐Ÿ”

The lookup_array is the range where Excel searches for your value. This is typically one column โ€” the IDs, names, or codes column in your reference table. Select just that column, not the entire table. Example: B2:B100 if IDs are in column B.

โ†ฉ๏ธ

The return_array is the column you want Excel to pull results from. It must be the same height as the lookup_array. Example: if lookup is B2:B100 and you want corresponding email addresses from column D, return_array is D2:D100.

โš ๏ธ

The if_not_found argument lets you specify what Excel returns when no match is found. Use "" for a blank, 0 for zero, or a descriptive message like "Not found". If omitted, Excel returns #N/A when there's no match.

โœ…

Match mode controls how Excel matches: 0 = exact match (default), -1 = exact or next smaller, 1 = exact or next larger, 2 = wildcard. For most use cases, leave this argument out and Excel uses exact match.

๐Ÿ”„

Search mode controls search direction: 1 = first to last (default), -1 = last to first (useful for finding most recent entries), 2 = binary search ascending, -2 = binary search descending. Binary search mode is significantly faster on well-sorted data with large datasets.

XLOOKUP Syntax Explained

The full XLOOKUP syntax is: =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode]). The three arguments in brackets are optional. In practice, most formulas use the first three or four arguments.

A basic formula looks like: =XLOOKUP(A2, Employees[ID], Employees[Email], "Not found"). This searches for the value in A2 within the ID column of the Employees table and returns the matching email. If no ID matches, it returns "Not found" instead of an error.

What makes XLOOKUP structurally different from VLOOKUP is that the lookup_array and return_array are completely independent. In VLOOKUP, you'd specify the whole table range and then a column number counting from the left โ€” =VLOOKUP(A2, B:F, 4, 0) means "look in B:F, return column 4". Change your table structure by inserting a column and your VLOOKUP column number is wrong. XLOOKUP references specific columns directly, so inserting or deleting columns doesn't break it.

XLOOKUP also supports returning multiple columns in one formula. If your return_array spans multiple columns โ€” for example D2:F100 instead of just D2:D100 โ€” Excel returns all three columns at once using dynamic arrays. This is a significant capability improvement over any single VLOOKUP formula, which could only return one column per formula. Managing large datasets becomes much cleaner when how to merge cells in Excel and range management concepts are well understood alongside XLOOKUP's multi-column return.

Understanding the search_mode argument is underrated by most users who learn XLOOKUP. The default mode searches top-to-bottom, which means it finds the first match in the lookup_array. In many business scenarios, you want the most recent match rather than the oldest โ€” for example, finding the latest transaction for a customer, the most recent price update for a product, or the last recorded status for an order.

Setting search_mode to -1 flips the search direction so XLOOKUP evaluates the lookup_array from bottom to top, returning the last match instead of the first. This eliminates the need for complex array formulas that previously handled "last match" lookups.

The match_mode argument gives XLOOKUP flexibility for approximate lookups. Setting match_mode to -1 (exact or next smaller) is the equivalent of the approximate match VLOOKUP used for tiered calculations โ€” salary bands, tax brackets, discount thresholds. Setting it to 2 enables wildcard matching, where you can use * to match any string. For example, looking up "Smith*" would match "Smith", "Smithson", or "Smithfield" โ€” handling partial-match scenarios cleanly.

XLOOKUP vs VLOOKUP vs INDEX/MATCH

๐Ÿ”ด XLOOKUP
๐ŸŸ  VLOOKUP
๐ŸŸก INDEX/MATCH

XLOOKUP Examples

๐Ÿ“‹ Basic Lookup

Scenario: You have a product table with product IDs in column A and prices in column C. You want to find the price for a given product ID.

Formula: =XLOOKUP(E2, A2:A100, C2:C100, "Not found")

This looks for the value in E2 within A2:A100 and returns the corresponding value from C2:C100. If no match exists, returns "Not found".

Why this beats VLOOKUP: In VLOOKUP you'd write =VLOOKUP(E2, A2:C100, 3, 0) โ€” the 3 means "third column from the left". Add a column between A and C and your formula is wrong. XLOOKUP references C2:C100 directly, so column changes don't affect it.

๐Ÿ“‹ Left Lookup

Scenario: You have employee names in column C and their IDs in column A (to the left of names). You want to find an ID by searching for a name.

Formula: =XLOOKUP(G2, C2:C100, A2:A100, "Not found")

VLOOKUP cannot do this natively because it requires the lookup column to be leftmost. With XLOOKUP, the lookup_array (C) and return_array (A) can be in any position โ€” including return_array being to the left of lookup_array. This use case alone eliminates dozens of workaround approaches that INDEX/MATCH was previously required for.

๐Ÿ“‹ Approximate Match

Scenario: You have a commission rate table. Sales under $10,000 earn 5%, $10,000โ€“$50,000 earn 8%, over $50,000 earn 12%. You want to look up an employee's commission rate based on their sales total.

Formula: =XLOOKUP(B2, D2:D4, E2:E4, "Check data", -1)

The match_mode of -1 means "exact or next smaller." If the sales value doesn't match exactly, Excel finds the largest value in the lookup array that's still less than the search value. This is equivalent to the approximate VLOOKUP (last argument = TRUE or 1), but clearer to read and doesn't require sorted data in all cases.

When to Use XLOOKUP vs Other Functions

XLOOKUP is the right choice for virtually any new lookup formula in Excel 365 or 2021. The syntax is cleaner than INDEX/MATCH, the left-lookup capability removes the biggest VLOOKUP constraint, and the native error handling is a quality-of-life improvement that matters in practice. For new workbooks shared exclusively among Excel 365 users, XLOOKUP should be your default.

VLOOKUP still makes sense when workbook compatibility with older Excel versions is a requirement. If the spreadsheet will be used by someone on Excel 2016 or 2019, VLOOKUP is safer than XLOOKUP because XLOOKUP will return #NAME? errors in those versions. In those situations, INDEX/MATCH is the better modern alternative when you need capabilities beyond VLOOKUP's rightward search constraint, since INDEX/MATCH works in all Excel versions.

For cleaning data before running any lookup, knowing how to remove duplicates in Excel is essential โ€” duplicate values in the lookup_array cause XLOOKUP to return only the first match, which can produce silent data errors if duplicates exist that shouldn't be there.

XLOOKUP is also the right choice when you need to return multiple columns. A single XLOOKUP formula with a multi-column return_array can replace three separate VLOOKUP formulas pointing at the same table. This not only simplifies the sheet but improves calculation performance since Excel evaluates one lookup instead of three.

Horizontal lookups โ€” where you're searching across a row rather than down a column โ€” work the same way in XLOOKUP. The lookup_array and return_array are simply row ranges instead of column ranges. This is equivalent to HLOOKUP, which XLOOKUP also replaces. Having one consistent function syntax for both vertical and horizontal lookups makes formula writing and auditing significantly easier.

XLOOKUP Checklist: Before You Write the Formula

Confirm you're using Excel 365, Excel 2021, or Excel Online โ€” XLOOKUP won't work in older versions
Identify your lookup_value: what you're searching for (usually a cell reference like A2)
Identify your lookup_array: the single column or row to search in (not the whole table)
Identify your return_array: the column or row to pull results from
Verify lookup_array and return_array are the same size (same number of rows or columns)
Decide if_not_found: use "" for blank, 0, or a message โ€” don't leave it blank if errors are a concern
Check for duplicates in lookup_array: XLOOKUP returns the first match only
If doing approximate match, confirm data is sorted correctly for match_mode -1 or 1

XLOOKUP Pros and Cons

Pros

  • Works in any direction โ€” left, right, up, or down
  • Returns multiple columns in one formula
  • Built-in if_not_found prevents #N/A errors
  • More readable syntax than INDEX/MATCH
  • Doesn't break when columns are inserted or deleted
  • Supports wildcard matching natively
  • Supports binary search for large sorted datasets

Cons

  • Only available in Excel 365, 2021, and Online โ€” not in 2019 or earlier
  • Workbooks using XLOOKUP show #NAME? errors when opened in older Excel
  • Still returns only the first match when duplicates exist in lookup_array
  • Learning curve if you're deeply familiar with VLOOKUP patterns
  • Dynamic array spill results can confuse users unfamiliar with Excel 365 features

Common XLOOKUP Errors and How to Fix Them

The #N/A error in XLOOKUP means no match was found in the lookup_array. This happens when the lookup_value doesn't exist in the lookup_array, when there are trailing spaces that make values look identical but not match, or when data types don't match (looking for the number 123 in a column of text "123"). Fix trailing spaces with TRIM() around the lookup_value. Fix data type mismatches by converting text to numbers using VALUE() or by formatting the column consistently.

The #NAME? error means Excel doesn't recognize XLOOKUP as a function โ€” you're on a version that doesn't support it. The fix is either to upgrade to a compatible Excel version or rewrite the formula using INDEX/MATCH or VLOOKUP.

The #VALUE! error usually indicates that lookup_array and return_array are different sizes. XLOOKUP requires them to have the same number of rows (for vertical lookups) or columns (for horizontal lookups). Check both ranges and make them match.

A common logic error is accidentally including a header row in the lookup_array or return_array. If your data starts in row 2 and headers are in row 1, your arrays should be B2:B100 not B1:B100. Including the header row means XLOOKUP might match against header text if someone enters that text as a lookup value, and it skews the row alignment between lookup and return arrays.

When XLOOKUP returns the wrong value even though no error appears, the most common culprit is duplicates in the lookup_array. XLOOKUP always returns the first match. If you need the last match (most recent entry for a customer, latest price update), set search_mode to -1, which searches from the last row to the first. Knowing how to freeze a row in Excel also helps when scrolling through large datasets to verify lookup results visually.

Test Your Excel Knowledge

XLOOKUP by the Numbers

2019
Year XLOOKUP was introduced in Excel 365
3
Required arguments (lookup_value, lookup_array, return_array)
6
Total arguments including optional ones
4
Search modes available (first-to-last, last-to-first, binary asc/desc)
4
Match modes: exact, next smaller, next larger, wildcard
0
Extra columns needed for left lookups (vs VLOOKUP workarounds)

XLOOKUP with Tables and Named Ranges

XLOOKUP works especially well with Excel Tables (the structured table format created by Insert โ†’ Table or Ctrl+T). When you reference a table column in XLOOKUP โ€” like Employees[Department] โ€” the formula automatically expands as new rows are added to the table. This means you don't have to update range references when data grows, which is one of the most common maintenance tasks in workbooks built on regular range references.

Named ranges are another clean approach. Instead of writing =XLOOKUP(A2, Sheet2!B2:B500, Sheet2!D2:D500), you can define named ranges like "EmployeeIDs" and "EmployeeSalaries" and write =XLOOKUP(A2, EmployeeIDs, EmployeeSalaries). The formula is much easier to read and audit, especially for colleagues who didn't build the workbook.

XLOOKUP also nests cleanly inside other functions. A common pattern is using XLOOKUP as the lookup_value for a second XLOOKUP โ€” this is useful for two-dimensional lookups where you need to find a value at the intersection of a matching row and a matching column. The equivalent in older Excel required an INDEX(MATCH(), MATCH()) construction that many users found difficult to write correctly. XLOOKUP makes the pattern much more readable.

For workbooks where data quality is critical, XLOOKUP pairs well with data validation โ€” how to create a drop down list in Excel so that lookup values entered by users are always constrained to valid options, which eliminates the majority of #N/A errors caused by typos or inconsistent formatting. Combining dropdown validation with XLOOKUP creates robust data entry workflows where lookup failures are nearly impossible.

One advanced application of XLOOKUP is using it to build dynamic lookups where both the lookup value and the return column are variables. Suppose you want users to select both a record identifier and a data field from dropdowns, and have Excel pull the intersection automatically. You can nest XLOOKUP inside another XLOOKUP โ€” the outer XLOOKUP finds the row, the inner XLOOKUP finds the column, and together they return the exact cell at the intersection. This approach replaces OFFSET or INDIRECT-based dynamic range formulas that were harder to read and more error-prone to maintain.

Practical XLOOKUP Tips for Real Work

Lock your lookup_array and return_array references when copying formulas down a column. If your lookup_array is B2:B100 and your return_array is D2:D100, write them as $B$2:$B$100 and $D$2:$D$100 with dollar signs. The lookup_value (A2) should remain relative so it changes as you copy down. Forgetting to lock the arrays is the most common reason XLOOKUP formulas produce wrong results when copied.

Use XLOOKUP's multiple-return capability to consolidate repetitive formulas. If you're pulling three pieces of information from the same table โ€” say, price, category, and supplier โ€” write one XLOOKUP with the return_array spanning three columns instead of three separate formulas. The result spills across three adjacent cells automatically. This reduces formula count, makes the workbook easier to maintain, and slightly improves calculation speed.

When working with case-sensitive data, XLOOKUP uses case-insensitive matching by default. "smith", "Smith", and "SMITH" all match the same lookup entry. If you need case-sensitive matching, you'll need to use a different approach โ€” typically EXACT() combined with an array formula. This is a rare requirement but worth knowing if you're working with data where case differences are meaningful.

For large datasets (tens of thousands of rows), XLOOKUP with search_mode 2 (binary search ascending) is significantly faster than the default first-to-last search. Binary search works by halving the search range repeatedly rather than checking every row sequentially. The requirement is that the lookup_array must be sorted in ascending order for binary search to return correct results. For sorted reference tables, this is a worthwhile performance setting.

XLOOKUP also interacts cleanly with conditional formatting and data validation. If you use XLOOKUP results as the basis for conditional formatting rules โ€” highlighting rows where the lookup returns a specific value, for example โ€” the formula evaluates dynamically as data changes, so the formatting stays accurate without manual updates. In dashboards and reporting templates that refresh regularly with new data, this combination makes the output far more maintainable than static approaches that require manual formatting review after every data update.

When auditing a workbook you didn't build, finding all XLOOKUP formulas is straightforward using Ctrl+F with the search term "XLOOKUP". Review each formula's lookup_array and return_array references to confirm they point to the correct ranges. Check whether the if_not_found argument is set โ€” blank if_not_found combined with lookup failures produces #N/A errors that surface unexpectedly in summary calculations. A few minutes of XLOOKUP audit work during handoff saves hours of troubleshooting after the original builder is no longer available to answer questions.

Practice Excel Functions

Excel XLOOKUP Questions and Answers

What is the difference between XLOOKUP and VLOOKUP?

XLOOKUP can search any column and return from any other column regardless of position, while VLOOKUP requires the lookup column to be the leftmost column in the range. XLOOKUP has a built-in if_not_found argument to handle missing matches cleanly, whereas VLOOKUP requires a separate IFERROR wrapper. XLOOKUP can also return multiple columns in one formula. VLOOKUP is available in all Excel versions; XLOOKUP requires Excel 365 or 2021.

Why is my XLOOKUP returning #NAME? error?

#NAME? in XLOOKUP means Excel doesn't recognize the function name. This almost always means you're using a version of Excel that doesn't support XLOOKUP โ€” typically Excel 2019 or earlier. XLOOKUP is only available in Excel 365, Excel 2021, and Excel Online. Check your Excel version under File โ†’ Account โ†’ About Excel. If you need to support older Excel versions, use INDEX/MATCH instead.

Can XLOOKUP return multiple columns at once?

Yes. Set the return_array to span multiple columns โ€” for example D2:F100 instead of D2:D100 โ€” and XLOOKUP returns all three columns as a dynamic array that spills across adjacent cells. This requires that the cells to the right of where you enter the formula are empty, otherwise Excel returns a #SPILL! error. This multi-column return capability replaces the need for multiple separate VLOOKUP formulas pointing at the same table.

How do I use XLOOKUP to look up to the left?

Set the lookup_array to the column you want to search and the return_array to a column that appears to its left. For example, if names are in column C and IDs are in column A, write =XLOOKUP(G2, C2:C100, A2:A100). XLOOKUP doesn't care about the left-right relationship between the arrays. This is a fundamental improvement over VLOOKUP, which required the lookup column to always be leftmost.

What does XLOOKUP return when it doesn't find a match?

By default (without the if_not_found argument), XLOOKUP returns #N/A when no match is found. To override this, add a fourth argument: =XLOOKUP(A2, B2:B100, D2:D100, "Not found"). The if_not_found value can be any text, number, blank string, or cell reference. Using "" returns a blank cell, which is often cleaner than displaying "Not found" in output tables.

Is XLOOKUP available in Google Sheets?

No. XLOOKUP is a Microsoft Excel function and isn't natively available in Google Sheets. Google Sheets has VLOOKUP and INDEX/MATCH, which cover most of the same use cases. Google Sheets does have XLOOKUP-like behavior through some array formula approaches, but there's no direct XLOOKUP equivalent. If you're frequently moving data between Excel and Google Sheets, INDEX/MATCH is the most portable lookup approach since it works in both applications.
โ–ถ Start Quiz