XLOOKUP function in Excel - powerful successor of VLOOKUP

The tutorial introduces XLOOKUP - the new function for vertical and horizontal lookup in Excel. Left lookup, last match, Vlookup with multiple criteria and a lot more things that used to require a rocket science degree to accomplish have now become as easy as ABC.

Whenever you need to look up in Excel, which function would you use? Is it a cornerstone VLOOKUP or its horizontal sibling HLOOKUP? In a more complex case, will you rely on the canonical INDEX MATCH combination or commit the job to Power Query? The good news is that you do not have choose anymore - all these methods are making way for a more powerful and versatile successor, the XLOOKUP function.

How is XLOOKUP better? In many ways! It can look vertically and horizontally, to the left and above, search with multiple criteria, and even return a whole column or row of data, not just one value. It has taken Microsoft over 3 decades, but finally they've managed to design a robust function that overcomes many frustrating errors and weaknesses of VLOOKUP.

What's the catch? Alas, there is one. The XLOOKUP function is only available in Excel for Microsoft 365, Excel 2021, and Excel for the web.

Excel XLOOKUP function - syntax and uses

The XLOOKUP function in Excel searches a range or an array for a specified value and returns the related value from another column. It can look up both vertically and horizontally and perform an exact match (default), approximate (closest) match, or wildcard (partial) match.

The syntax of the XLOOKUP function is as follows:

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

The first 3 arguments are required and the last three are optional.

  • Lookup_value - the value to search for.
  • Lookup_array - the range or array where to search.
  • Return_array - the range or array from which to return values.
  • If_not_found [optional] - the value to return if no match is found. If omitted, an #N/A error is returned.
  • Match_mode [optional] - the match type to perform:
    • 0 or omitted (default) - exact match. If not found, an #N/A error is returned.
    • -1 - exact match or next smaller. If an exact match is not found, the next smaller value is returned.
    • 1 - exact match or next larger. If an exact match is not found, the next larger value is returned.
    • 2 - wildcard character match.
  • Search_mode [optional] - the direction of search:
    • 1 or omitted (default) - to search from first to last.
    • -1 - to search in reverse order, from last to first.
    • 2 - binary search on data sorted ascending.
    • -2 - binary search on data sorted descending.

    According to Microsoft, binary search is included for advanced users. It is a special algorithm that finds the position of a lookup value within a sorted array by comparing it to the middle element of the array. A binary search is much faster than a regular search but works correctly only on sorted data.

Basic XLOOKUP formula

To gain more understanding, let's build an Xlookup formula in its simplest form to perform an exact lookup. For this, we will only need the first 3 arguments.

Supposing, you have a summary table with information about the five oceans on the Earth. You want to get the area of a specific ocean input in F1 (lookup_value). With the ocean names in A2:A6 (lookup_array) and areas in C2:C6 (return_array), the formula goes as follows:

=XLOOKUP(F1, A2:A6, C2:C6)

Translated into plain English, it says: search for the F1 value in A2:A6 and return a value from C2:C6 in the same row.
Excel XLOOKUP function

No column index numbers, no sorting, no other ridiculous quirks of Vlookup! It just works :)
XLOOKUP formula in Excel


Compared to traditional VLOOKUP, XLOOKUP has many advantages. Here's a list of the best 10 features that blow the doors off any other lookup function in Excel:

  1. Vertical and horizontal lookup. The XLOOKUP function got its name due to its ability to look up both vertically and horizontally.
  2. Look in any direction: right, left, bottom or up. While VLOOKUP can only search in the leftmost column and HLOOKUP in the topmost row, XLOOKUP has no such limitations. The notorious left lookup in Excel is not a pain anymore!
  3. Exact match by default. In most situations, you will be looking for an exact match, and XLOOKUP returns it by default (unlike the VLOOKUP function that defaults to approximate match). Of course, you can get XLOOKUP to perform an approximate match too if needed.
  4. Partial match with wildcards. When you know only some part of the lookup value, not all of it, a wildcard match comes in handy.
  5. Search in reverse order. Earlier, to get the last occurrence, you had to reverse the order of your source data. Now, you simply set the search_mode argument to -1 to force your Xlookup formula to search from the back and return the last match.
  6. Return multiple values. By manipulating with the return_array argument, you can pull an entire row or column of data related to your lookup value.
  7. Search with multiple criteria. Excel XLOOKUP handles arrays natively, which makes it possible to perform lookup with multiple criteria.
  8. If error functionality. Traditionally, we use the IFNA function to trap #N/A errors. XLOOKUP incorporates this functionality in the if_not_found argument allowing to output your own text if no valid match is found.
  9. Column insertions/deletions. One of the most irritating issues with VLOOKUP is that adding or removing columns breaks a formula because the return column is identified by its index number. With XLOOKUP, you supply the return range, not number, meaning you can insert and remove as many columns as you need without breaking anything.
  10. Better performance. VLOOKUP could slow down your worksheets because it includes the entire table in calculations, which results in processing far more cells than actually needed. XLOOKUP handles only the lookup and return arrays that it truly depends on.

How to use XLOOKUP in Excel - formula examples

The following examples demonstrate the most useful XLOOKUP features in action. Additionally, you will discover a couple non-trivial uses that will take your Excel lookup skills to a new level.

Look up vertically and horizontally

Microsoft Excel used to have two functions for different lookup types, each having its own syntax and usage rules: VLOOKUP to look vertically in a column and HLOOKUP to look horizontally in a row.

The XLOOKUP function can do both with the same syntax. The difference is in what you provide for the lookup and return arrays.

For v-lookup, supply columns:

=XLOOKUP(E1, A2:A6, B2:B6)

Vertical XLOOKUP

For h-lookup, enter rows instead of columns:

=XLOOKUP(I1, B1:F1, B2:F2)

Horizontal XLOOKUP

Left lookup performed natively

In earlier versions of Excel, INDEX MATCH formula was the only reliable way to look to the left or above. Now, you no longer need to combine two functions where one would suffice. Just specify the target lookup array, and XLOOKUP will handle it without a problem regardless of its location.

As an example, let's add the Rank column to the left of our sample table. The goal is to get the rank of the ocean input in F1. VLOOKUP would stumble here because it can only return a value from a column to the right of the lookup column. An Xlookup formula copes with ease:

=XLOOKUP(F1, B2:B6, A2:A6)

Left XLOOKUP in Excel

In a similar manner, you can look above when searching horizontally in rows.

XLOOKUP with exact and approximate match

The match behavior is controlled by the 5th argument called match_mode. By default, an exact match is performed.

Please pay attention that even when you choose an approximate match (match_mode set to 1 or -1), the function will still search for an exact match first. The difference is in what it returns if an exact lookup value is not found.

Match_mode argument:

  • 0 or omitted - exact match; if not found - #N/A error.
  • -1 - exact match; if not found - next smaller item.
  • 1 - exact match; if not found - next larger item.

Exact match XLOOKUP

This is the option you probably use 99% of the time you do lookup in Excel. Since an exact match is XLOOKUP's default behavior, you can omit match_mode and supply only the first 3 required arguments.

In some situations, however, an exact match won't work. A typical scenario is when your lookup table does not contain all the values, but rather "milestones" or "bounds" like quantity-based discounts, sales-based commissions, etc.

Our sample lookup table shows the correlation between exam scores and grades. As you can see in the screenshot below, an exact match works only when the score of a particular student matches the value in the lookup table exactly (like Christian in row 3). In all other cases, an #N/A error is returned.

=XLOOKUP(F2, $B$2:$B$6, $C$2:$C$6)

Exact match XLOOKUP

To get the grades instead of #N/A errors, we need to look for an approximate match as shown in the next example.

Approximate match XLOOKUP

To perform an approximate lookup, set the match_mode argument to either -1 or 1, depending on how your data is organized.

In our case, the lookup table lists the lower bounds of the grades. So, we set match_mode to -1 to search for the next smaller value when an exact match is not found:

=XLOOKUP(F11, $B$11:$B$15, $C$11:$C$15, ,-1)

For example, Brian has the score of 98 (F2). The formula searches for this lookup value in B2:B6 but cannot find it. Then, it searches for the next smaller item and finds 90, which corresponds to grade A:
Approximate match XLOOKUP to return the next smaller value

If our lookup table contained the upper bounds of the grades, we would set match_mode to 1 to search for the next larger item if an exact match fails:

=XLOOKUP(F2, $B$2:$B$6, $C$2:$C$6, ,1)

The formula searches for 98 and again cannot find it. This time, it tries to find the next larger value and gets 100, corresponding to grade A:
Approximate match XLOOKUP to return the next larger value

Tip. When copying an Xlookup formula to multiple cells, lock the lookup or return ranges with absolute cell references (like $B$2:$B$6) to prevent them from changing.

XLOOKUP with partial match (wildcards)

To perform a partial match lookup, set the match_mode argument to 2, which instructs the XLOOKUP function to process the wildcard characters:

  • An asterisk (*) - represents any sequence of characters.
  • A question mark (?) - represents any single character.

To see how it works, please consider the following example. In column A, you have a few smartphone models and, in column B, their battery capacity. You are curious about the battery of a certain smartphone. The problem is that you are not sure you can type the model name exactly as it appears in column A. To overcome this, enter the part that is definitely there and replace the remaining characters with wildcards.

For example, to get information about the battery of iPhone X, use this formula:

=XLOOKUP("*iphone X*", A2:A8, B2:B8, ,2)

Or, input the known part of the lookup value in some cell and concatenate the cell reference with the wildcard characters:

=XLOOKUP("*"&E1&"*", A2:A8, B2:B8, ,2)

XLOOKUP with wildcard match

XLOOKUP in reverse order to get last occurrence

In case your table contains several occurrences of the lookup value, you may sometimes need to return the last match. To have it done, configure your Xlookup formula to search in reverse order.

The direction of search is controlled be the 6th argument named search_mode:

  • 1 or omitted (default) - searches from first to last value, i.e. top-to-bottom with vertical lookup or left-to-right with horizontal lookup.
  • -1 - searches in reverse order from last to first value.

As an example, let's return the last sale made by a specific salesperson. For this, we put together the first three required arguments (G1 for lookup_value, B2:B9 for lookup_array, and D2:D9 for return_array) and put -1 in the 5th argument:

=XLOOKUP(G1, B2:B9, D2:D9, , ,-1)

Straightforward and easy, isn't it?
XLOOKUP in reverse order to get the last match

XLOOKUP to return multiple columns or rows

One more amazing feature of XLOOKUP is its ability to return more than one value relating to the same match. All is done with the standard syntax and without any extra manipulations!

From the below table, supposing you want to retrieve all the details pertaining to the salesperson of interest (F2). What you need to do is supply a range, not a singe column or row, for the return_array argument:

=XLOOKUP(F2, A2:A7, B2:D7)

You enter the formula in the top-left cell of the results range, and Excel automatically spills the results into adjacent blank cells. In our case, the return array (B2:D7) includes 3 columns (Date, Item and Amount), and all three values are returned into the range G2:I2.
XLOOKUP to return multiple columns

If you'd rather arrange the results vertically in a column, nest XLOOKUP into the TRANSPOSE function to flip the returned array:


XLOOKUP multiple values and transpose a row to column.

In a similar fashion, you can return an entire column of data, say the Amount column. For this, use cell F1 that contains "Amount" as lookup_value, the range A1:D1 containing the column headers as lookup_array and the range A2:D7 containing all data as return_array.

=XLOOKUP(F1, A1:D1, A2:D7)

XLOOKUP to return entire column

Note. Because multiple values are populated into neighboring cells, make sure you have enough blank cells to the right or down. If Excel cannot find enough empty cells, a #SPILL! error occurs.

XLOOKUP with multiple criteria

Another big advantage of XLOOKUP is that it handles arrays natively. Due to this ability, you can evaluate multiple criteria directly in the lookup_array argument:

XLOOKUP(1, (criteria_range1=criteria1) * (criteria_range2=criteria2) * (…), return_array)

How this formula works: The result of each criteria test is an array of TRUE and FALSE values. The multiplication of the arrays converts TRUE and FALSE into 1 and 0, respectively, and produces the final lookup array. As you know, multiplying by 0 always gives zero, so in the lookup array, only the items that meet all the criteria are represented by 1. And because our lookup value is "1", Excel takes the first "1" in lookup_array (first match) and returns the value from return_array in the same position.

To see the formula in action, let's pull an amount from D2:D10 (return_array) with the following conditions:

  • Criteria1 (date) = G1
  • Criteria2 (salesperson) = G2
  • Criteria3 (item) = G3

With dates in A2:A10 (criteria_range1), salesperson names in B2:B10 (criteria_range2) and items in C2:C10 (criteria_range3), the formula takes this shape:

=XLOOKUP(1, (B2:B10=G1) * (A2:A10=G2) * (C2:C10=G3), D2:D10)

Though the Excel XLOOKUP function processes arrays, it works as a regular formula and is completed with a usual Enter keystroke.
XLOOKUP with multiple criteria

The XLOOKUP formula with multiple criteria is not limited to "equal to" conditions. You are free to use other logical operators as well. For example, to filter orders made on the date in G1 or earlier, put "<=G1" in the first criterion:

=XLOOKUP(1, (A2:A10<=G1) * (B2:B10=G2) * (C2:C10=G3), D2:D10)


To find a value at the intersection of a certain row and column, perform the so-called double lookup or matrix lookup. Yep, Excel XLOOKUP can do that too! You simply nest one function inside another:

XLOOKUP(lookup_value1, lookup_array1, XLOOKUP(lookup_value2, lookup_array2, data_values))

How this formula works: The formula is based on XLOOKUP's ability to return an entire row or column. The inner function searches for its lookup value and returns a column or row of related data. That array goes to the outer function as the return_array.

For this example, we are going to find the sales made by a particular salesperson within a certain quarter. For this, we enter the lookup values in H1 (salesperson name) and H2 (quarter), and do a two-way Xlookup with the following formula:

=XLOOKUP(H1, A2:A6, XLOOKUP(H2, B1:E1, B2:E6))

Or the other way round:

=XLOOKUP(H2, B1:E1, XLOOKUP(H1, A2:A6, B2:E6))

Where A2:A6 are the salesperson names, B1:E1 are quarters (column headers), and B2:E6 are data values.

A two-way lookup can also be performed with an INDEX Match formula and in a few other ways. For more information, please see Two-way lookup in Excel.


When the lookup value is not found, Excel XLOOKUP returns an #N/A error. Quite familiar and understandable to expert users, it might be rather confusing for novices. To replace the standard error notation with a user-friendly message, type your own text into the 4th argument named if_not_found.

Back to the very first example discussed in this tutorial. If someone inputs an invalid ocean name in E1, the following formula will explicitly tell them that "No match is found":

=XLOOKUP(E1, A2:A6, B2:B6, "No match is found")



  • The if_not_found argument traps only #N/A errors, not all errors.
  • #N/A errors can also be handled with IFNA and VLOOKUP, but the syntax is a bit more complex and a formula is lengthier.

Case-sensitive XLOOKUP

By default, the XLOOKUP function treats lowercase and uppercase letters as the same characters. To make it case-sensitive, use the EXACT function for the lookup_array argument:

XLOOKUP(TRUE, EXACT(lookup_value, lookup_array), return_array)

How this formula works: The EXACT function compares the lookup value against each value in lookup array and returns TRUE if they are exactly the same including the letter case, FALSE otherwise. This array of logical values goes to the lookup_array argument of XLOOKUP. As the result, XLOOKUP searches for the TRUE value in the above array and returns a match from the return array.

For example, to get the price from B2:B7 (return_array) for the item in E1 (lookup_value), the formula in E2 is:

=XLOOKUP(TRUE, EXACT(E1, A2:A7), B2:B7, "Not found")

Case-sensitive XLOOKUP

Note. If there are two or more exactly the same values in the lookup array (including the letter case), the first found match is returned.

Excel XLOOKUP not working

If your formula does not work right or results in error, most likely it's because of the following reasons:

XLOOKUP is not available in my Excel

The XLOOKUP function is not backward compatible. It's only available in Excel for Microsoft 365 and Excel 2021, and won't appear in earlier versions.

XLOOKUP returns wrong result

If your obviously correct Xlookup formula returns a wrong value, chances are that the lookup or return range "shifted" when the formula was copied down or across. To prevent this from happening, be sure to always lock both ranges with absolute cell references (like $A$2:$A$10).

XLOOKUP returns #N/A error

An #N/A error just means the lookup value is not found. To fix this, try searching for approximate match or inform your users that no match is found.

XLOOKUP returns #VALUE error

A #VALUE! error occurs if the lookup and return arrays have incompatible dimensions. For instance, it is not possible to search in a horizontal array and return values from a vertical array.

XLOOKUP returns #REF error

A #REF! error is thrown when looking up between two different workbooks, one of which is closed. To fix the error, simply open both files.

As you have just seen, XLOOKUP has many awesome features that make it THE function for almost any lookup in Excel. I thank you for reading and hope to see you on our blog next week!

Practice workbook for download

Excel XLOOKUP formula examples (.xlsx file)

You may also be interested in

56 comments to "XLOOKUP function in Excel - powerful successor of VLOOKUP"

  1. Geoffrey Davis says:

    I'm trying build out an excel file using two sheets. I'm trying to use the ID# from column A sheet one to find said ID# from sheet two. Then I'd like it to search for the row title from sheet 1 on sheet 2 to pull sheets 2s value into sheet 1. Is this possible?

  2. Loysss says:

    How would you use the function of xlookup in excel? And what was the function names before as?

    Someone can answer this please. Thanks in advance 🙂

  3. Andrea says:

    Hi! I'm trying to use XLOOKUP for the following situation but I don't know how to do so the number of cals finds the right pricing tier.
    I have 1 table with 14 columns: a) a CONCAT formula to add in 1column the centre, market & channel info (BsAsARGcall) b) different pricing tiers, under 4000 calls there's a price for each centre, market & channel and the same for every tier: over 8000, over 10000 calls, etc there's a different price according to amount of contacts
    In another table I have a column with another CONCAT formula same info as above (centre, market,channel) and then the column with amount of calls per centre, market, channel.
    What I need to do is for the XLOOKUP to find the right price by searching the right tier column (under 4000, over 8000, etc) and bring the right price according to the amount of calls. Any help? Hope I was able to explain myself clearly :-)

  4. Clémence Robert says:

    I need to retrieve data under certain conditions from one sheet to another, and here is the formula I am using: =XLOOKUP((IF(OR('by sample'!$H4="cheek, right",'by sample'!$H4="cheek, left"),'by sample'!$H4,"")),'by sample'!$H4:$H1000,'by sample'!B4:B1000,,0).
    It works well, but when the results is N/A I would like excel to find the next xlookup value.
    I am trying to write an IFNA of the sort: IFNA(XLOOKUP(...), find next xlookup value) to avoid removing the cells manually/with find and select tool, but without success...
    How could I proceed?

  5. christy says:

    I am trying to copy down the XLOOKUP function to use it for an entire column but it is changing the search array.
    XLOOKUP(B1, C2:C6, D3:D7) then when I copy down I want XLOOKUP(B2, C2:C6, D3:D7) but I get XLOOKUP(B2, C3:C7, D4:D8). It shifts all by 1 cell instead of just the search value.

    How do I get it to automatically shift the search but not the other 2 array?


  6. Bryony Maguire says:

    Hello - has this replaced the use of Transpose and Filter? I used to use this formula to look up an array that had multiple instances and returns in one column: "=TRANSPOSE(FILTER(C2:C6, B9=B2:B6))". Where C2:C6 had the expected outputs (more than one output but only in one column) B9 is the criteria to lookup and B2;B6 is the array to look for it in.
    When I use it now I need a NAME error which seems to indicate its no longer a recognized formula name.
    I cant find the equivalent in the xlookup formula i.e. where the multiple responses are all in the same column.

  7. Steve says:

    Very informative, thank you. I was particularly interested in XLOOKUP with multiple criteria. You use:

    XLOOKUP(1, (criteria_range1=criteria1) * (criteria_range2=criteria2) , return_array)

    I had not seen this before, and previously I had used concatenation, for example:

    XLOOKUP(criteria1 & criteria2, criteria_range1 & criteria_range2, return_array)

    But this can be very slow if you are referencing whole columns. Do you know if your approach is faster? I suspect it would be.

      • Steve says:

        Thanks Alexander. Yes I appreciate that using specific ranges is faster than entire columns. In some models though I find column references are preferable, as the formulas are easier to read and you don't have to worry about users adding new data to rows outside the range.

        I guess my question is, *for a given range of data*, whether there is a significant difference in speed between the two XLOOKUP approaches above. I might have a play around to see.

  8. Marcus says:

    Hi -
    this may not be an xlookup question.

    I have one sheet with a list of protein names in column A, and on another sheet, a list of biological pathways (column A), with the corresponding proteins that are found in that pathway listed across columns B-Z in that row. Every pathway has column B filled (at least 1 protein per pathway), but after that has a variable number of entries depending on how many proteins are associated with that pathway (from 1 up to 25, with any remaining cells blank). All proteins on sheet 2 are contained in the list on sheet 1, and vice versa. There should be no "not founds".

    I want to enter a formula in sheet 1 by which sheet 2 will be searched for each protein name and for each, return which pathways it is associated with, returning those pathway names into sheet 1, column B (and C and D and so on until all relevant pathways are listed).

    a small made up example, separate column entries separated by pipes
    sheet 1 (single letter protein names)

    sheet 2 (pathway name|protein|protein|protein)

    desired results, sheet 1:

    Any help appreciated.

  9. Mészáros Kornél says:

    Do you know what is the correct syntax if I would like to implement the following query inside of a VBA code? =XLOOKUP(1, (B2:B10=G1) * (A2:A10=G2) * (C2:C10=G3), D2:D10)
    I would like to implement the following, which works well in pasted in a cell:
    =XLOOKUP(1;(Elisa!$J$2:$J$2015=BH$2)*(Elisa!$B$2:$B$2015=$AY7);Elisa!$E$2:$E$2015;" ")
    What I have tried:
    Worksheets("Adatbázis").Cells(H, I).Value = WorksheetFunction.XLookup(1, (Worksheets("Elisa").Range("J2:J2015") = Cells(2, I)) * (Worksheets("Elisa").Range("B2:B2015") = Cells(H, 51)), Worksheets("Elisa").Range("E2:E2015"), " ")
    This always ends with a Tyme mismatch message around this part: Worksheets("Elisa").Range("J2:J2015") = Cells(2, I). I have tried it several ways but no luck so far...

  10. Thomas says:

    I really like the xlookup function but I am struggling with a situation I am unable to resolve.

    I want to use the xlookup to find a transaction in a check register and put that transaction in a budget report. I am able to get xlookup to find a single line item for a budget category but when a category has multiple entries xlookup is only returning the first line item of that category. What I am after is not only to find the first transaction of a particular category but to find all of them and add(sum) them all together into one cell. ex: find all amounts paid for groceries then sum them all together.

    I am using the date & category as a reference to find the amount paid in each category. Here is the formula I am using it only finds the first transaction. How do I need to change it to find all transactions and sum them all together in one cell?

    =IFERROR(XLOOKUP($J$4&F15,'Arvest Savings'!$C:$C&'Arvest Savings'!$E:$E,'Arvest Savings'!$H:$H,,0),"")

    The above formula is going into the budget form under the actual column then once the entry is made in the check register it automatically populates into the budget form for the appropriate month,

    It works great for a single transaction where I need assistance is with finding multiple transactions and getting them summed all together.

  11. Maddy says:

    how does xlookup work for multiple tables - two similar sets of data, one for onshore and one for offshore. I have Line of work (Java, testing etc), Designation (Manager, Team lead, etc), rate for line of work vs designation. This calculation is straight forward if its only for offshore or onshore. Now If i have to get both in one formula should I use IFERROR ?

  12. Richard Davies says:

    I'm struggling with XLOOKUP and dates with multiple criteria. Please help!
    I'm trying to return a Lab value for a particular ID collected on a date that is closest to, but before or equal to, the Clinic Date.
    For example for ID: A251527 on Clinic Date 17/09/2008 (in cells E2 and F2 respectively).
    The answer should be 130 on 12/08/2008 but XLOOKUP using multiple criteria seems to return the Lab value on the first date for this ID (124).

    =XLOOKUP(1, ($A$2:$A$17="ID")*(LARGE($B$2:$B$17,COUNTIF($B$2:$B$17,">"&$F$2)+1)<=F2), $C$2:$C$17)

    The data is unsorted and is large ~110,000 rows.

    Clean ID Date Collected Lab value ID Clinic date
    A251300 17/09/2008 118 A251527 17/09/2008
    A251300 16/09/2008 129
    A251527 13/06/2008 124
    A251527 16/06/2008 115
    A251527 18/06/2008 114
    A251527 23/06/2008 113
    A251527 24/06/2008 108
    A251527 24/06/2008 113
    A251527 12/08/2008 130
    A251527 03/11/2008 133
    A251527 19/02/2009 120
    A251527 20/02/2009 112
    A251527 21/02/2009 122
    A251527 22/02/2009 138
    A252601 19/08/2008 136
    A252601 10/02/2009 117

    • Hello!
      You cannot apply XLOOKUP approximate search on unsorted data.
      If I got you right, the formula below will help you with your task:

      =INDEX(C2:C17,MATCH(MAX(IFERROR((B2:B17-E2) / ((A2:A17=D2)*((B2:B17-E2)<0)),-100000)), (A2:A17=D2)*(B2:B17-E2),0))

      In Excel 365:

      =VLOOKUP(E2,SORT(FILTER(B2:C17,(B2:B17 < E2)*(A2:A17=D2)),2,1),2,1)

      I hope my advice will help you solve your task.

      • Richard Davies says:

        Thanks for replying.
        Your VLOOKUP formula for Excel 365 seems to be missing some arguments at the end? Can you complete please?

  13. Mustafa says:

    thank you for the post, very useful
    how can I set the Xlookup function to get the first, second, and third result on arranged set when working with multiple data in a table

  14. Hardik says:

    i'm trying to find out Balance Work = Scope of work - Work Done, but result always wrong.
    Please help, how to i get final result with XLOOKUP or any other function.
    Below given data is Length (m) (From-To).

    Scope of work - Work Done = Balance Work
    From To From To
    62000 66000 68000 68480
    67200 71080 68680 69300
    72000 73400 73000 73180
    73650 75500 76300 76600
    76300 76600
    77400 78080
    78300 79100
    79300 79600

      • Hardik says:

        This data is related to Highway construction. in which digit shows location of highway. Terms used means:
        1. Scope of work = Construction work to be execute at that locations. (A)
        2. Work Done = Construction work has been done. (B)
        3. Balance Work = Remaining work, which is to be execute within scope of work. (C=A-B) (Result)
        4. From = Starting Point of work (62+000)
        5. To = Ending Point of work (66+000)
        (From) 62+000 - (To) 66+000 = 4000 m (Length)

        Scope of work (A) Work Done (B) Balance Work (A-B) (Result)
        From To Length From To Length From To Length
        62+000 66+000 4000 62+000 66+000 4000 68+085 69+630 1545
        67+200 71+080 3880 67+200 68+085 885 70+015 70+065 050
        72+000 73+400 1400 69+630 70+015 385 72+000 72+100 100
        - 70+065 71+080 1015 73+175 73+310 135
        - 72+100 73+175 1075
        - 73+310 73+400 090
        This is highway measurement that's why i used 4 columns.
        I have Scope & Work Done Data and i would like to calculate Balance Work.
        I hope this will helpful to understand.
        Please Help !

  15. Phil says:

    I have a strange issue with XLookup and structured referencing, and I cannot for the life of me work out what I’m doing wrong.
    =XLookup(A2,B:B,G:G) works, but =Xlookup(A2,Table1[ColumnB],Table1[ColumnG]) doesn’t - I get a #VALUE ERROR. Column G contains numbers. There are no spaces or other things that usually cause value errors.
    I don’t think the problem is with my syntax. The table is named Table1, and the two columns are named as above. I have used xlookup in the same format referencing other tables in the worksheet with no issues.
    Any help appreciated.

  16. Gunjan Singh says:

    Hi everyone,
    I need to perform XLOOKUP such that the criteria is Difference/Subtraction between two cells of column X and column Y. Suppose Quarter 1,2 as columns and i need to check rows where element/value of Quarter2 - element/value of Quarter1 = 25.

    In other words rows in which the difference/subtraction of Column X and Column Y is exactly equal to 25

  17. Nitesh says:

    I need to find and list all possible matches for a 'PART NAME" within a column containing FULL NAMES. Example:
    2. ADAM JOHN

    I need to do an XLOOKUP to list all matching Rows containing "JOHN"

    • Hello!
      XLOOKUP can only return one match, not a list of values. If you need to return a list of values that contain "JOHN", use this tutorial: How to VLOOKUP multiple values in Excel.

      =IFERROR(INDEX($A$1:$A$10, SMALL(IF(ISNUMBER(SEARCH($B$1,$A$1:$A$10,1)), ROW($A$1:$A$10)-1,""), ROW()-1)),"")

      This array formula is on line 2. Copy it down the column.
      I hope I answered your question. If you have any other questions, please don’t hesitate to ask.

  18. Bujji says:

    Please help how to retrieve the values using vba.

    Excel Sheet Name: Source.xlsx (Column: G -> Code)
    Excel Sheet Name: Mappings.xlsx (Column: A -> Node; Column: B -> Code)

    In Mappings.xlsx sheet:
    When I filter by Code = 001 in Column B, there are 3 rows shown as a result with Column: A values as "001", "00100100", "00100")

    So basically one Code has multiple Nodes. I want to retrieve all the Nodes for a specific Code in vba.

    I tried with Xlookup, but its retrieving only one value for me and not all the 3 values.

  19. Shawn says:

    Thanks for your info on XLOOKUP, it was very helpful. Correct my thinking here in case it's wrong, but the XLOOKUP multiple criteria is used to construct an array (column or row) of data but can't return a multi-dimensional array (area) to be searched. Originally I was trying figure out how to use multiple criteria to filter results from a long data table during the XLOOKUP function and wasn't getting anywhere when I realized that I needed to filter the results before I performed the Xlookup. Using the concept of array-based inputs for XLOOKUP, I came up with this ...


    D3 is the value I want to filter by
    A:A is the column I want to filter
    A:T are the columns I want FILTER to return to INDEX
    0 is the value I want to search for
    T (20) is the column I want to search
    Q (17) is the column I want to return data from

    This allows a custom filter to be applied to the data without modifying the original at all and returns it to the function instead of placing it in a temporary or new cell location. The FILTER functions can also have SORT applied to them before the INDEX for the bitwise searches that require it. Just make sure that what is fed to each INDEX part of the function are identical. I'm posting this here as a search for XLOOKUP combined with FILTER like this doesn't come up in any searches.

  20. KJ says:

    HI, I have a dataset with staff completing their inspections on specific dates for certain street addresses.
    Header rows:
    2) Segment
    4)Approx. Blocks
    5)# Inspectors
    6) Bureau
    7)Team Lead
    8)Completed 12/7
    9)Completed 12/8
    10)Completed 12/9
    11)Completed 12/10
    12)Completed 12/11

    If I want to get the latest value from #8-#12 columns, what syntax can I use?

  21. Dave Quinn says:

    Thanks this is great! For some reason the search in reverse order is not working.
    Using your example my sheet has (=XLOOKUP(G1,B2:B9,D2:D9, ,-1)) still gives me $25 as the result, not $45.
    All the other examples seem to work great

    • Hi Dave,

      Thank you for pointing out this issue!

      It looks like Microsoft has changed the order of arguments in the XLOOKUP function! At the moment of writing, this function was a beta available for Office Insiders. That time, search_mode that controls the direction of search was the 5th argument. Now, it's the last (6th) argument. I will review and update all the affected examples ASAP.

      In the meantime, please use this formula to get the last occurrence:
      =XLOOKUP(G1, B2:B9, D2:D9, , ,-1)

  22. Olivier says:

    Hi Svetlana,
    Very complete but I am stuck with a more complex issue.
    I need to get a value based on 3 criteria, including one that is an approximate (i.e. lookup value would be within a range)
    My formula looks like this:
    =xlookup(Value01&Value02&Value03,Range01&Range02&Range03,ReturnRange,,-1) where value 03 is the approximate crlteria.

    The ranges are same lenghts and side by side. It should work however it gives me random return values, never consistent.

    Please help.

  23. JoJo says:

    I have multiple Xlookup's running in my workbook, but I'm having issues with a particular one. I have a column with pay type data (regular time, overtime) and another column where the job name is listed. I am attempting to use xlookup to determine which pay type AND if the job name is one of 3 possibilities (referencing a range of cells for that data) have it return a job type number listed in another range of cells. My current formula is =XLOOKUP($E2,AC2:AC5&($T1,AE2:AE5),AD2:AD5,E2)which returns "regular time" as the answer (which I only want it to do if it won't be replacing the data with information from the proper range). I have to be missing part of the query, but I'm not sure where.

    • Hello!
      I’m sorry but your task is not entirely clear to me. Could you please describe it in more detail?
      What do you want to determine using this formula? Pay type? Job type? What is written in cell E2? What is written in cell T1? You are using 3 ranges of AC2: AC5 AE2: AE5 AD2: AD5. What is written in them? Without this, I cannot understand the logic of your formula

  24. Robert Kellogg says:

    Is it possible to utilize an XLOOKUP in conjunction with a range? I'd like to return a value based on a range that varies depending on the lookup criteria.

    Example. Criteria one is a customer name, Criteria two is their sales, Result/Return is a order frequency. There is 5 possible return values of what the order frequency should be based on the range of sales and the customer name. There are different ranges based on customer names.

    • Hello Robert!
      Read carefully the section above "XLOOKUP with multiple criteria" You did not explain what you mean by "order frequency".
      I’m sorry but your task is not entirely clear to me. For me to be able to help you better, please describe your task in more detail. Please specify what you were trying to find, what formula you used and what problem or error occurred. Give an example of the source data and the expected result.
      It’ll help me understand it better and find a solution for you. Thank you.

  25. Stephane says:

    I am trying to work out this formula =IF(A2>0,"Non Compliance","Compliance")but i want to exclude blank cells. How do i do that?


Post a comment

Thank you for your comment! When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to your query. We cannot guarantee that we will answer every question, but we'll do our best :)