How To Use Xlookup In Excel: A Complete Guide For Beginners

You Have a Spreadsheet Full of Data and Need Answers Fast

You are staring at an Excel sheet with thousands of rows. In one column, you have product IDs. In another table, you have the corresponding prices. Your job is to pull the correct price for each ID into your main report. You remember VLOOKUP, but it always feels clunky. It breaks if you insert a column, it can’t look to the left, and dealing with errors is a chore.

This is the exact moment Microsoft designed XLOOKUP for. It is not just another function. It is a complete replacement for VLOOKUP, HLOOKUP, and even INDEX-MATCH for most everyday tasks. If you have ever been frustrated by Excel’s older lookup tools, learning XLOOKUP will change how you work with data.

What Makes XLOOKUP Different

Before we dive into the steps, it helps to understand why XLOOKUP is such a big deal. Traditional VLOOKUP has four main pain points. It can only search the first column of a table. It uses column index numbers that break if your table structure changes. It defaults to an approximate match, which can cause errors. And it has no simple way to say “if not found, return this instead.”

XLOOKUP solves all of this with a simpler, more powerful syntax. You tell it what to look for, where to look, and where to get the answer from. That is it. You can search in any direction, handle missing values gracefully, and even perform two-way lookups with a single formula. It is the lookup function you always wanted.

The Core Syntax of XLOOKUP

Every XLOOKUP formula is built on the same foundation. The function has three required arguments and two optional ones. Here is the basic structure.

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

Let us break down what each piece means.

  • lookup_value: This is what you are searching for, like a specific product ID or employee name.
  • lookup_array: This is the range of cells where Excel should search for your lookup_value.
  • return_array: This is the range of cells containing the value you want to bring back, like the price or department.
  • if_not_found (optional): What to display if no match is found, like “Not Found” or 0.
  • match_mode (optional): Specify an exact match (0), exact match or next smaller item (-1), exact match or next larger item (1), or a wildcard match (2).
  • search_mode (optional): Define search order, like first-to-last (1) or last-to-first (-1).

The beauty is in the simplicity. The lookup_array and return_array can be anywhere on the sheet. They do not need to be part of a formal table, and the return_array can be to the left of the lookup_array. This flexibility is a game-changer.

Your First XLOOKUP: A Step-by-Step Example

Imagine a simple dataset. In cells A2:A10, you have a list of Employee IDs (EMP101, EMP102, etc.). In cells B2:B10, you have their corresponding names. In a separate cell, E2, you type an Employee ID. You want the formula in F2 to return the matching employee’s name.

Here is exactly what you would do.

Click on cell F2. Type an equals sign to start the formula. Begin typing XLOOKUP. Excel’s formula auto-complete will show the function. You can either type the full name or select it from the list.

Now, build the formula argument by argument. Your lookup_value is the ID you typed in E2. So, click on cell E2 or type E2. Add a comma.

Next, the lookup_array. This is where Excel searches for the ID from E2. That is our list of IDs in column A. Click and drag to select range A2:A10, or type A2:A10. Add another comma.

Finally, the return_array. This is where the answer (the name) lives. Select the range B2:B10. Your formula in the formula bar should now look like this.

=XLOOKUP(E2, A2:A10, B2:B10)

Press Enter. If the ID in E2 exists in column A, the corresponding name from column B will appear in F2. Change the ID in E2, and the name updates instantly. You have just performed a basic, exact-match lookup. Notice you did not have to count columns or worry about the return column being to the right of the lookup column.

Going Beyond the Basics: Handling Errors and Multiple Criteria

The real power of XLOOKUP becomes clear when you use its optional arguments. Let us tackle the common “Not Found” error first. In our example, if you type an ID in E2 that does not exist in column A, the formula returns #N/A.

To make your report cleaner, use the if_not_found argument. Modify the formula in F2.

how to use xlookup

=XLOOKUP(E2, A2:A10, B2:B10, “ID Not in List”)

Now, if the lookup fails, the cell will display the text “ID Not in List” instead of an error. You can use any text, a blank (“”), or a number like 0.

What if you need to look up a value based on two pieces of information? For instance, finding a price based on both a Product ID and a Region. You can combine XLOOKUP with other functions. One elegant method is to use the ampersand (&) to create a combined lookup key.

Assume Product IDs are in A2:A100, Regions are in B2:B100, and Prices are in C2:C100. You have a target Product ID in E2 and a target Region in F2. The formula in G2 would be.

=XLOOKUP(E2&F2, A2:A100&B2:B100, C2:C100, “Not Found”)

This is an array formula. In modern versions of Excel, you simply press Enter. Excel concatenates the values in the two lookup columns to create a single, unique search key (like “PROD123East”), and finds the matching concatenated key in your data. It then returns the corresponding price.

Replacing VLOOKUP and INDEX-MATCH with XLOOKUP

If you have existing spreadsheets with VLOOKUP, converting them to XLOOKUP makes them more robust. Take a typical VLOOKUP formula.

=VLOOKUP(H2, $A$2:$D$100, 3, FALSE)

This looks for H2 in the first column of A2:D100 and returns the value from the third column of that range (column C). To convert this to XLOOKUP, you identify the parts.

  • lookup_value: H2
  • lookup_array: $A$2:$A$100 (the first column of the old VLOOKUP table)
  • return_array: $C$2:$C$100 (the specific column you want to return)

The new XLOOKUP formula is.

=XLOOKUP(H2, $A$2:$A$100, $C$2:$C$100, “Not Found”)

This formula is now immune to column insertions or deletions within your data table. If someone adds a new column between A and C, the XLOOKUP still points directly to column C. The VLOOKUP would break, returning data from the new column instead.

For those who use the powerful but complex INDEX-MATCH combo, XLOOKUP is a simpler, all-in-one alternative. An INDEX-MATCH formula looks like this.

=INDEX($C$2:$C$100, MATCH(H2, $A$2:$A$100, 0))

The equivalent XLOOKUP is the same formula we just created. It does the job of both functions in one, with clearer syntax.

Performing Two-Way Lookups with XMATCH

Sometimes you need to find a value at the intersection of a specific row and column, like a price for a certain product in a certain month. This is called a two-way lookup. XLOOKUP can handle this elegantly when nested with its companion function, XMATCH.

Imagine a price table where products are in column A (A2:A50) and months are in row 1 (B1:M1). The prices fill the grid B2:M50. To find the price for “Gadget X” in “March”, you would use two XLOOKUPs or combine XLOOKUP with XMATCH.

how to use xlookup

Here is the XLOOKUP and XMATCH method. The formula uses one XLOOKUP to get the correct row (the product) and another to get the correct column (the month).

=XLOOKUP(“March”, B1:M1, XLOOKUP(“Gadget X”, A2:A50, B2:M50))

Let us read this from the inside out. The inner XLOOKUP finds “Gadget X” in the product list A2:A50. Its return_array is the entire block of prices for that product, B2:M50. This returns a single row of data. The outer XLOOKUP then takes that row and looks for “March” within the month headers B1:M1, returning the value at the intersecting cell.

Common Mistakes and How to Avoid Them

Even with a superior function, errors happen. The most common issue is a mismatch in array sizes. The lookup_array and return_array must be the same dimensions. If you try to look up in A2:A100 but return from B2:B90, Excel will return a #VALUE! error. Always double-check your range selections.

Another frequent challenge is numbers stored as text, or vice versa. If your lookup_value is the number 100, but the values in your lookup_array are the text string “100”, an exact match will fail. Use the VALUE or TEXT functions to convert data types, or ensure consistency from the start.

Forgetting the optional arguments can also lead to messy sheets. Not using the if_not_found argument leaves #N/A errors scattered about, which can break downstream calculations. Get in the habit of including a default value, even if it is just an empty string.

When to Use Wildcard Matching and Search Modes

The match_mode and search_mode arguments unlock advanced behaviors. Set match_mode to 2 for wildcard matches. This lets you use the asterisk (*) to represent any number of characters and the question mark (?) for a single character.

For example, to find the first product name in a list that starts with “Pro”, you could use.

=XLOOKUP(“Pro*”, A2:A100, B2:B100, , 2)

The search_mode argument is useful for finding the last occurrence of an item. Setting search_mode to -1 tells Excel to search from the bottom of the list upward. This is perfect for finding the most recent entry for a recurring item, like the last transaction for a client.

=XLOOKUP(“ClientA”, A2:A100, C2:C100, , 0, -1)

This formula will start at the bottom of the list in A100 and go up until it finds “ClientA”, then return the corresponding value from column C, which is likely the most recent record.

Integrating XLOOKUP into Your Real Workflows

XLOOKUP is not just for simple sheets. You can nest it inside IF statements for conditional logic. You can use it with FILTER to extract multiple matches. You can even reference entire columns for dynamic, spill-proof lookups in Excel Tables.

For dynamic reports, combine XLOOKUP with data validation drop-down lists. Let the user select a value from a validated list, and use that cell as the lookup_value. The report updates instantly, creating an interactive dashboard feel without any complex macros.

Remember, the goal is to save time and reduce errors. Start by replacing one VLOOKUP in your most-used spreadsheet. See how it works. Then, convert another. The more you use XLOOKUP, the more you will appreciate its straightforward power and reliability.

Your data is waiting. Stop wrestling with old, fragile formulas. With XLOOKUP, you have a precise, flexible tool that works the way you think. It turns complex data retrieval into a simple question and answer, letting you focus on the insights, not the mechanics of the lookup.

Leave a Comment

close