In this article, learn all about the XLOOKUP Excel function, it’s syntax, parameters and how to use it with real-world xlookup examples.

What is XLOOKUP?
Using XLOOKUP, we can search for an item in a list using the lookup value and return a matching item. For example, you can lookup for salesperson “Jackie” and return their sales amount from the data below using the XLOOKUP function, as depicted above.
It is the newest member of Excel’s lookup function family. You may already know the other members of this group – VLOOKUP, LOOKUP, HLOOKUP, INDEX+MATCH.
How to use XLOOKUP – step by step instructions
Let’s say you have data for salespeople like above and you want to find the Net Sales for “Jackie”. Follow below steps to create the XLOOKUP function in Excel.
- Write =XLOOKUP( in a cell
- For the lookup_value, Type the name of the salesperson in double quotes (ex: “Jackie”)
- Tip: If you have the name of the person in a cell (like G4), you can point to the cell instead of typing the name
- Now for the lookup_array, select the names column of your data.
- and for the return_array, select the net sales column of your data.
- Close the brackets and hit enter.
- Congratulations, you’ve just created your first XLOOKUP formula in Excel.
Here is how the formula and result look in my data:

What if the lookup value is not in the lookup array?

One of the most common scenarios of lookups in Excel is not finding the value you are looking for. Imagine, you are looking for the salesperson “Chandoo”, but he doesn’t exist in the dataset. In this case, XLOOKUP will return #N/A error.
But we can use the 4th parameter of XLOOKUP – if_not_found to set an optional value to display when there is an error.
Here is an example formula with that:
=XLOOKUP("Chandoo", B4:B21, D4:D21, "Not found")
How to lookup in the middle with XLOOKUP (INDEX MATCH replacement)?

Let’s say you want to lookup the sales amount of $726 and return the name of the person (in this case, Jessy). Previously, you needed to use the INDEX+MATCH combination for this. But XLOOKUP let’s us specify any range or column for lookup_array portion. so, no more INDEX+MATCH… Yay!

To perform the “net sales” lookup and return the name of the person, we can use the below formula:
=XLOOKUP(G4, G4:G21, G4:G21, "Not found")
The above XLOOKUP example assumes that G4 contains the net sales value you want to lookup.
How to lookup higher than / lower than using XLOOKUP? (approximate match)

Say, you want to find out the closest person with the net sales of $1300. In this case, we don’t have anyone with that value in the data. You can still use XLOOKUP to get the approximate matching value, either next higher or lower in the data.
For this we can use the 5th parameter of the XLOOKUP function – match mode.
There are 4 match modes in XLOOKUP.
- 0 or Exact match. This is the default value for XLOOKUP.
- 1 or next larger match. This looks up for the exact or next highest value in the lookup array.
- -1 or next smaller match. This looks up for the exact or next lowest value in the lookup array.
- 2 or wildcard match. This looks up based on a pattern you have mentioned in the lookup value. More on this further down in the article.
To get the next highest matching value:
=XLOOKUP(G4,D4:D21,B4:B21,,1)
Note: 1 refers to next higher value for match mode.
The above formula returns “Jonathan” in the sample data, as he has the next highest amount – $1316.
To get the next lowest matching value:
=XLOOKUP(G4,D4:D21,B4:B21,,-1)
Note: 11 refers to next lower value for match mode.
This formula returns “John” as he has the next lower value – $1088.
Getting Partial Matches with XLOOKUP (Wildcard / Pattern Matching)
XLOOKUP also allows for a powerful and elegant pattern matching in your data. Let’s say you want to find the net sales for the person whose name begins with the letters Jam. In this case, we can use the match mode 2 (wild card) along with the wildcard operators * (asterisk) and ? (question mark) to create our XLOOKUP.

To find the net sales of the person whose name begins with Jam,
- Use the formula =XLOOKUP(H4&”*”,B4:B21,D4:D21,”No such person”,2)
- Here H4 contains the first few letters of the name, i.e. Jam
- The lookup value is H4 & “*”. This tells XLOOKUP that we want the name to begin with the value of H4 (Jam) and then there can be any number of characters.
- Rest of the XLOOKUP parameters are as per usual.
- Don’t forget the match mode operator as 2. We need this for Wild card – pattern matching.
Refer to above illustration for more on the pattern matching xlookup.
Additional Pattern Matching Tricks with XLOOKUP
Refer to below handy table for some extra tips on using the partial matching feature of XLOOKUP.
| Situation | Formula | Explanation | Sample Result |
|---|---|---|---|
| Name ends with ved | =XLOOKUP(“*ved”, B4:B21,D4:D21,”No such person”,2) | To find a word ending with, we use * (asterisk) at the beginning of the pattern | Javed, $2277 |
| Name contains ack | =XLOOKUP(“*ack*”, B4:B21,D4:D21,”No such person”,2) | We can use two * symbols – one at the beginning of the pattern and one at the end. | Jackie, $1610 |
| Name has 5 letters and begins with Je | =XLOOKUP(“Je???”,B4:B21,D4:D21,,2) | In this case, we can use the ? (question mark) symbol to indicate that we can have any one character. So the pattern is Je??? | Jessy, $726 |
| Name begins with J and ends with d | =XLOOKUP(“J*d”, B4:B21, D4:D21,”No such person”, 2) | J*d means the lookup value begins with J, contains any number of letters and ends with d | Javed, $2277 |
What if there are two matching values?

If you have more than one matching item for the lookup value in your data, XLOOKUP, just like all other lookup functions in Excel, will always return the first matching item’s corresponding value.
As you can see in the above illustration, we have two sales persons with the name Johnson in our data.
When using =XLOOKUP(“Johnson”, B4:B21, D4:D21) we are going to get the net sales of the first Johnson ie $1540.
But what if I need to get the second or third or all the matching values?
In this case, you can use the new FILTER() function in Excel to get the second or all matching items.
Here is the formula.
=FILTER(D4:D21,B4:B21="Johnson")
For more information on FILTER function, refer to this article.
Horizontal Lookup with XLOOKUP (HLOOKUP replacement):

XLOOKUP works just as good with horizontal data too, thus replacing any need for HLOOKUP function.
In the above example, I have monthly budget table and I want to lookup the budget value for April 2024.
We can use this XLOOKUP formula to do just that.
=XLOOKUP(C10,C3:N3,C4:N4)
Returning entire row of information with XLOOKUP:
Another powerful feature of XLOOKUP is that it can return multiple values all corresponding to the same lookup value. For example, I want to see the budget, actual and balance information for the month of April 2024, from my budget spreadsheet below. We can use XLOOKUP for that easily.
=XLOOKUP(C10,C3:N3,C4:N6)
In the above formula, by using multiple rows (C4:N6) as the return array, we can return all corresponding values for the lookup value in C10 – ie April 2024. Excel will automatically spill these values into separate cells on the worksheet.

XLOOKUP – things to keep in mind:
When using XLOOKUP, you must keep these points in mind:
- XLOOKUP needs Excel 365 or Excel on the web or Excel 2021: This function is not available in all the versions of Excel. So check your version of Excel before you start using xlookup. If you notice #NAME errors when working with XLOOKUP, that means your version of Excel does not support this function. Instead, use INDEX+MATCH formula.
- Use the If not found option to fix errors: To avoid any lookup errors (#N/As), use the fourth argument of the XLOOKUP function – if_not_found.
- Lock cell references when creating lookups: If you are writing multiple XLOOKUPs in a range, don’t forget to lock your cell references to absolute mode (change B4:B21 to $B$4:$B$21) so that when you drag or fill the formula down, your lookup and return array ranges don’t change. This is a common mistake and you will end up with wrong results. (absolute vs. relative references)
- Or better yet, convert your lookup data to a table: A simple fix to the relative reference issue is to use tables on your data. This way, you can write simple XLOOKUP formulas like this: =XLOOKUP(“Jackie”,sales[Sales Person],sales[Net Sales])
- In case of multiple matches, XLOOKUP always returns the first (or last matching item, if you used search mode option) value. This is why it is important to also learn how to use the FILTER function in Excel.
How is XLOOKUP better?
- XLOOKUP makes the most used formula in Excel straight forward and less error prone. You just write =XLOOKUP(what you want to find, the list, the result list) and boom, you get the answer (or #N/A error if the value is not found)
- Looks up exact match by default: One of the annoyances of VLOOKUP is that you must mention FALSE as last parameter to get correct result. XLOOKUP fixes that by doing exact matches by default. You can use match mode parameter to change the lookup behavior if you want.
- 4th parameter to support value not found scenario In most business situations, we are forced to wrap our lookup formulas with IFERROR or IFNA formulas to suppress errors. XLOOKUP offers 4th parameter (read more about it below) so you can tell what default output you want if your value is not found.
- XLOOKUP offers optional parameters to search for special situations. You can search from top or bottom, you can do wildcard searches and faster options to search sorted lists.
- It returns reference as output, not the value. While this may not mean much for normal users, pro Excel user’s eyes light up when they discover a formula that can return refs. That means, you can combine XLOOKUP outputs in innovative ways with other formulas. For example: XLOOKUP to create dependant drop down in Excel.
- It is so much cooler to type, you just type =XL. I am not sure if this is a happy coincidence but saying =XL to get this formula is just awesome.
XLOOKUP Syntax
Simple case:
=XLOOKUP(what you want to look, lookup list, result list)
=XLOOKUP("Jackie", sales[Sales Person], sales[Net Sales])
returns Jackie’s [Net Sales] if the name can be found in [Sales Person]
Optional parameters:
By default, you just need 3 parameters for XLOOKUP, as shown above. But you can also use 4th, 5th and 6th parameter to specify how you want the lookup to be done.
4th parameter for XLOOKUP: IF not found (no more IFERROR!!!)
The newly introduced XLOOKUP has an even newer feature. It now supports if not found option. This is the 4th parameter.
For example, use:
=XLOOKUP(“Chandoo”, sales[Sales Person], sales[Net Sales],”Value not found”) to return “Value not found” if the lookup value is not available in the search column – sales[Sales Person].
5th parameter for XLOOKUP: Match mode or type:
Use this to tell Excel how you want your MATCH to happen. The default is 0 (exact match) but you can also use these other options, shown below.

6th parameter for XLOOKUP: Search mode
Try this if you want to search from bottom to top. The default direction is top down (1).

XLOOKUP with two sheets

If you have data in two seperate sheets (or files), you can use XLOOKUP to quickly combine the data and get what you want.
Refer to my XLOOKUP with two sheets article for detailed instructions and formula examples.
XLOOKUP – Video Tutorial:
Here is a simple but effective video tutorial on how to use XLOOKUP function and how it can replace VLOOKUP and INDEX+MATCH functions. You can also watch the xlookup tutorial on my channel.
Download XLOOKUP examples – workbook
Click here to download the 13 XLOOKUP examples file.
And one more example file, this with INDEX+MATCH replacements.
Final thoughts on XLOOKUP
In my opinion, XLOOKUP is a terrific function and a must have for any data professional. It is part of my essential Excel formulas list for data analysts.
When we nest XLOOKUP formulas, we can also perform more complex lookups like 2-WAY lookups or search across different worksheets. I discuss some of these advanced scenarios in a recent video on my YouTube channel. Please watch it here.
The only downside of XLOOKUP is the compatibility. It doesn’t work in all versions of Excel. For this reason, I still think there is value in learning how to use VLOOKUP and INDEX MATCH functions.
Do let me know what you think about XLOOKUP and if you have any questions about it using the comments section.
Learn more about Data Analysis with Excel:
This post is part of my data analysis with Excel series. Please learn other topics too and improve your data skills with Excel.
- How to use Excel Tables – 13 time saving tips
- How to use Dynamic Array functions in Excel such as Filter, Unique, Sort etc.
- Working with Power Query in Excel to save time and shine at work
- Know more about XLOOKUP with my course










15 Responses to “Compare 2 Lists Visually and Highlight Matches”
Hi,
I solved this in a little different way.
We have 2 lists, one starts at A1 and other at B1, both are vertical arrays.
First thing is define 2 named ranges, list1 and list2:
list1 refers to "=OFFSET(Sheet1!$A$1;0;0;SUMPRODUCT(--(Sheet1!$A$1:$A$1000""));1)"
list2 refers to "=OFFSET(Sheet1!$A$1;0;0;SUMPRODUCT(--(Sheet1!$B$1:$B$1000""));1)"
this way lists will be dynamically sized when you had or remove elements (you can't have blanks and you can't have more than 1000 elements).
Then I use conditional formatting in column A when this formula is true:
"=NOT(ISERROR(MATCH(A1;list2;0)))"
and "=NOT(ISERROR(MATCH(B1;list1;0)))" to list2.
This way we eliminate the need for auxiliary columns or lists.
Hope you like my way! 😀
Nunes
Simple conditional formatting formula.
Assuming lists vertical lists starting in A1 & B1
To highlight just one column (assume B for example)
Conditional formatting>New Rule>by formula
=MATCH(B1,$A$1:$A$99,0)
Set the cell fill to what ever color you prefer & press OK
To highlight both columns repeat with this formula for cell in column A
=MATCH(A1,$B$1:$B$99,0)
This approach doesn't require named fields or addtl columns
glw
Say I had 1 list in A2:A20 and another in B2:B20.
To format all the items in column A that are repeated in column B I would use the following Conditional Formatting rule.
=IF(ISNA(VLOOKUP(A2,$B$2:$B$20,1,false)),true,false)
All the duplicates are highlighted. It us a very simple example of comparison.
I may be missing something here, but I usually highlight both my lists by holding ctrl eg A1:A20 E10:E40 then choose conditional formatting from the ribbon and then highlight duplicates, and this does it?
Lee, I was perplexed as well. I do the same thing you do with the conditional formating. A drag and click to highlight range and choose highlight duplicates does the trick for me.
I believe these methods are to check if an item from one list also appears in the other list. So if an item mentioned many times in one list if also mentioned in the other list or not.
The Conditional Formatting highlight duplicates feature will do this, but it will also highlight an item if it appears multiple times in the one column or list.
Hi, I would just like to know (if you are willing to share) which image editing program you use to make your image like above, like they are torn apart from bottom? I've been looking for long.
@i48998
Chandoo is on Holidays, but Chandoo uses Paint.Net
Paint.net is a free download available at http://www.paint.net/
.
I use CorelDraw/PhotoPaint
.
We both use the Snipping Tool (a freebe with Win Vista/10)
.
We both use Camtasia for doing screen captures to make animated GIFs where you see animation.
Here is how I would accomplish
(1) Define Names: List_1, List_2
(2) =ISNA(MATCH(D4,List_2,0))-1 (Conditional Format formula List_1)
(3) =ISNA(MATCH(D4,List_1,0))-1 (Conditional Format formula List_2)
ISNA will return 1 if NO Match and O if Match by adding a -1 will make: NO Match 0 and Match a -1 which is True
Hi all
this my first Post here
i think we can take Unique List for tow list to know what is not Duplicate By this Array formula
=IFERROR(INDEX($D$6:$D$33,SMALL(IF(ISERROR(MATCH($D$6:$D$33,$B$6:$B$33,0)),ROW($D$6:$D$33)-ROW($D$6)+1),ROWS($J$5:J5))),"")
and this one for Duplicate Value
=IFERROR(INDEX($D$6:$D$33,SMALL(IF(ISNUMBER(MATCH($D$6:$D$33,$B$6:$B$33,0)),ROW($D$6:$D$33)-ROW($D$6)+1),ROWS($J$5:J5))),"")
Don't forget to Enter This Formula by Pressing Ctrl+Shift+Enter
without wanting to ruthlessly self promote here, I do have an addin that does neatly compare two ranges, not just in columns, so you might want to check that out.
Having said that this is a pretty neat solution if you dont want to be going down the VBA or purchase route. I like it
however, could you not do something with the remove duplicates feature in Excel 2010 and then compare the resulting data set?
Hi, Chandoo! I've found yesterday your Excel website... What can I say? It's just awesome, Excellent. Being a developer for 30 years, more than 15 with Office products, and wow!, how many things I discovered in a couple of hours, and what pretty resolved.
I decided to take the long path of the newbies and read all your examples and write down by myself all of them, and when I arrived to this (the comparison of two lists) I think I've found a problem:
a) in "Step 4: Apply conditional formatting to Second List - Use the same logic, but this time the rule becomes =COUNTIF(count1s,$H6)" it should say "Step 4: Apply conditional formatting to Second List - Use the same logic, but this time the rule becomes =COUNTIF(count1s,$H6)>0", but this is a typing error that I believe all of us here might have discovered and corrected
b) the very problem: I wrote down two different lists, in different ranges, and with different number of elements, I specified the equivalent conditional formats, et non voilá!, I didn't get what expected. So I downloaded your example book, I checked range names, formulaes, conditional formats and all OK. So I copied -just values- from my book to yours, and I still couldn't achieve the goal.
I'm using Excel 2010 in spanish, I'm from Buenos Aires (Argentina), and my book is at your disposition whenever you considerate it appropiate.
Thanks in advance for your time, and again my congratulations for your work here.
Best regards.
SirJB7
Comparison of 2 lists visually with highlights
Author: SirJB7 / Date: 11-Dic-2011
Pros: no duplicated tables, no matrix formulaes, no named ranges, no VBA code, just conditional formatting
Cons: not found yet, comments and observations welcome
Features:
a) standard problem: highlights in orange/yellow elements existing in the other list
b) optimized problem: idem a) plus highlights in red/violet first occurrence of elements existing in the other list
Sheet contents:
a) conditional format, 1 rule per list (2 methods used)
A1:A20, first list
B1:B20, second list
a1) range A1:A20, condition =NO(ESERROR(BUSCARV(A1;B$1:B$20;1;FALSO))), format Orange ---> in english: =NOT(ISERROR(VLOOKUP(A1,B$1:B$20,1,FALSE)))
a2) range B1:B20, condition =CONTAR.SI(A$1:A$20;B1)>0, format Yellow ---> in english: =COUNTIF(A$1:A$20,B1)>0
b) conditional format, 2 rules per list (2 methods used)
D1:D20, first list
E1:E20, second list
b1) range E1:E20, condition 1 =Y(NO(ESERROR(BUSCARV(D1;E$1:E$20;1;FALSO)));COINCIDIR(D1;D$1:D$20;0)=FILA(D1)), format Red ---> in english: =AND(NOT(ISERROR(VLOOKUP(D1,E$1:E$20,1,FALSE))),MATCH(D1,D$1:D$20,0)=ROW(D1))
same range, condition 2 and format 2, same as a1)
b2) range E1:E20, condition =Y(CONTAR.SI(D$1:D$20;E1)>0;COINCIDIR(E1;E$1:E$20;0)=FILA(E1)), format Violet ---> in english: =AND(COUNTIF(D$1:D$20,E1)>0,MATCH(E1,E$1:E$20,0)=ROW(E1))
same range, condition 2 and format 2, same as a2)
Personally I like the a2) and b2) solutions, I think the formulaes are prettier.
I still don't know the rules of this website and forum, but it any precept is infringed I'm willing to share the workbook with the solution. If it breaks a rule, I apologize and promise that won't happen again.
Best regards for all!
Dear All i have a complicated situation...
1. I have two sheets of data Sheet1 and Sheet2 (from various sources) - Both of these contain data matching and Not matching as well..
2. Now for me i need to build an excel where in i need to get sheet 3 with values that are present in a column of Sheet 1.
What ever Sheet 1 doesn't have i dont want those rows from sheet 2 to be populated into Sheet3.
Can any one help me out.
Hi Team
The above example is to compare partial name from 2 different columns.
If I want to cross check it in a single column. I have both correct and partial correct/match entries in a column. Is there any way I can find both the entries in the column.
Regards