Skip to main content

XLOOKUP() vs. VLOOKUP(): A Comparison for Excel Users

XLOOKUP() searches in any direction, defaults to exact matches, and has built-in error handling, while VLOOKUP() only searches right and needs manual column indexing.
· 11 min read

Explore with AI

Add DataCamp as preferred source on Google

XLOOKUP() is the better lookup function for most Excel users: it searches in any direction, defaults to an exact match, keeps working when you insert columns, and handles missing values without IFERROR(). VLOOKUP() still has a place when you share workbooks with people on Excel 2019 or older, because XLOOKUP() isn’t available there.

Microsoft announced XLOOKUP() in 2019 as the successor to VLOOKUP(). In this article, I compare the two side by side: syntax, the main differences, worked examples, the errors each one throws, and how to choose between them.

Bear in mind, the shift from VLOOKUP() to XLOOKUP() is just one of many Excel updates. Staying current with Excel's evolving functions is important for maximizing productivity. So check out the Excel Fundamentals skill track to make sure you are using the latest features.

TL;DR

  • Use XLOOKUP() when everyone who opens the file has Microsoft 365, Excel 2021 or later, or Google Sheets.
  • Keep VLOOKUP() for workbooks that people open in Excel 2019 or older.
  • XLOOKUP() defaults to an exact match; VLOOKUP() defaults to an approximate match that can quietly return wrong values.
  • XLOOKUP() can look left, survives inserted columns, and returns several columns in one formula.
  • Its if_not_found argument replaces wrapping VLOOKUP() in IFNA() or IFERROR().

XLOOKUP() and VLOOKUP() SyntaxXLOOKUP() replaces VLOOKUP()'s table and column number with two ranges

Both functions find a value in one range and return a related value from another. They differ in how you tell Excel where to search and what to return.

Syntax of VLOOKUP()

Let’s take a look at the VLOOKUP() syntax. 

=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

In the above formula:

  • lookup_value is the value you want to search for. This can be a number, text, or a reference to a cell containing the search value.

  • table_array is the range of cells that contains the data. The first column in this range must contain the lookup_value.

  • col_index_num is the column number in the range from which you want to retrieve the value. 

  • range_lookup (optional) sets the match type: FALSE (or 0) for an exact match, TRUE (or 1) for an approximate match. If you leave it out, VLOOKUP() uses an approximate match, which only works when the first column is sorted in ascending order.

Syntax of XLOOKUP()

XLOOKUP() has six arguments to VLOOKUP()’s four, but only the first three are required.

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

In the above formula:

  • lookup_value is the value you want to search for.

  • lookup_array is the range of cells where the lookup value is searched.

  • return_array is the range of cells that contains the value you want to return.

  • if_not_found (optional) returns a value if no match is found. If the value is not specified, it returns #N/A.

  • match_mode (optional) determines the type of match to perform. 0 is for exact match (default). -1 is for the exact match or the next smaller item. 1 is for the exact match or the next larger item. 2 is for the wildcard character match.

  • search_mode (optional) determines the search mode to use. 1 is used to search from first to last (default). -1 is used to search from last to first. 2 runs a binary search on data sorted in ascending order, and -2 on data sorted in descending order. On unsorted data, both binary modes return wrong results.

Main Differences: XLOOKUP() vs. VLOOKUP()

Every difference below favors XLOOKUP(). VLOOKUP()’s one advantage, working in every version of Excel, is covered under Performance and Compatibility.

Exact match mode 

XLOOKUP() defaults to an exact match, but VLOOKUP() needs FALSE as its fourth argument to get one. The default matters because an approximate match on unsorted data doesn’t fail predictably. It can return a plausible-looking wrong value, or #N/A for a value that is in the table.

VLOOKUP without its fourth argument returns #N/A for Jane on unsorted data, while XLOOKUP returns her salary

Exact match difference between XLOOKUP() and VLOOKUP(). Source: Image by Author.

I left out VLOOKUP()’s fourth argument, so it ran an approximate match on the unsorted names and returned #N/A for Jane, even though she’s in the table. XLOOKUP() finds her salary because it uses an exact match by default.

Lookup direction

VLOOKUP() always searches the first column of the table array and can only return values from columns to its right. But XLOOKUP() can search for values in any direction.

VLOOKUP returns #N/A because the grade column is left of the names, while XLOOKUP returns Robin's grade

Lookup direction difference between VLOOKUP() and XLOOKUP(). Source: Image by Author.

Here, VLOOKUP() didn’t find grades because it can only search for data to the right of the lookup_value (student name). In comparison, XLOOKUP() finds the grades for Robin because it can search in either direction (left or right).

Array references

In VLOOKUP(), you have to define the entire data range (table array) and specify the column number (column index) containing the desired output (return column) within a single formula. XLOOKUP() is more flexible than this. It allows you to define separate arrays for the lookup value and the data you want to return. 

VLOOKUP takes one table range and a column number, while XLOOKUP takes separate lookup and return ranges

Array references between VLOOKUP() and XLOOKUP(). Source: Image by Author.

Horizontal lookup

VLOOKUP() doesn't allow you to perform horizontal searches. If you want a horizontal search, you would have to use HLOOKUP() instead. XLOOKUP() consolidates these two functions because it performs both vertical and horizontal lookups so you don’t have to use separate functions for different lookup directions.

VLOOKUP can't search a row, while XLOOKUP and HLOOKUP return prices from the horizontal table

Horizontal lookup difference between VLOOKUP() and XLOOKUP(). Source: Image by Author.

Handling column insertions/deletions 

Inserting or deleting a column inside the table array breaks VLOOKUP(), because the hardcoded col_index_num now points at a different column. XLOOKUP() references the return column directly, so Excel updates the reference and the formula keeps working.

After a column is inserted, VLOOKUP returns a last name instead of a salary, while XLOOKUP still returns 70000

XLOOKUP() remains unaffected, while VLOOKUP() fails. Source: Image by Author.

Approximate match and sorting

VLOOKUP()’s approximate match only works when the first column is sorted in ascending order. On unsorted data it returns wrong results without warning. XLOOKUP()’s approximate modes, match_mode -1 (next smaller) and 1 (next larger), work on unsorted data.

For example, with score thresholds in A2:A6 and letter grades in B2:B6, this formula returns the grade for the highest threshold at or below 87, in whatever order the thresholds are listed:

=XLOOKUP(87, A2:A6, B2:B6, , -1)

On the same unsorted table, the equivalent =VLOOKUP(87, A2:B6, 2, TRUE) returned F when I ran it in Excel. It only gives the right answer if A2:A6 is sorted from smallest to largest.

On an unsorted grade table, XLOOKUP returns B for a score of 87 while VLOOKUP's approximate match returns F

Approximate match on unsorted data in XLOOKUP() and VLOOKUP(). Source: Image by Author.

XLOOKUP can search in both ascending and descending order, while VLOOKUP is limited to ascending order.

 

Custom error messages

VLOOKUP() shows an #N/A error when no match is found. XLOOKUP() has an optional if_not_found argument that lets you return your own text, a number, or another formula instead. You can get the same result from VLOOKUP() by wrapping it in IFNA() or IFERROR(), but that means two functions instead of one.

XLOOKUP returns a custom Not found message for a missing student, while VLOOKUP returns #N/A

Customizing error messages in XLOOKUP() and VLOOKUP(). Source: Image by Author.

You can see VLOOKUP() couldn't find the student in its list and displayed a #N/A error. Similarly, the XLOOKUP() function could not locate the student's name. However, unlike VLOOKUP(), XLOOKUP() returns a specific message when there's no match.

Return multiple values

VLOOKUP() can return only one value at a time. But XLOOKUP() can retrieve values from multiple columns simultaneously. Give it a multi-column return_array, such as C2:E10, and the results spill into the neighboring cells, so one formula replaces several VLOOKUP() formulas.

One XLOOKUP formula returns name, department, and salary for ID 1004, while VLOOKUP returns only the name

Returning multiple values with XLOOKUP() and VLOOKUP(). Source: Image by Author.

Search mode

VLOOKUP() looks through a list from the beginning and only returns the first value that matches what you want. XLOOKUP() can also scan from the bottom up with search_mode -1, which returns the last match, such as the most recent entry in a log sorted by date.

VLOOKUP returns Alice's first CGPA of 3.5, while XLOOKUP searching last to first returns her latest, 3.75

Difference between VLOOKUP() and XLOOKUP(). Source: Image by Author.

Here, VLOOKUP() retrieves the first occurrence, which is from the first semester. However, with XLOOKUP(), I use the search mode code -1 to search from the bottom up.

Multiple criteria

VLOOKUP() matches on one column, so a lookup on two conditions usually needs a helper column that joins them. XLOOKUP() can test several columns in one formula: multiply the conditions into an array of 1s and 0s, then look up 1.

=XLOOKUP(1, (A2:A10="Sarah")*(C2:C10=2023), B2:B10)

XLOOKUP multiplies two conditions to find Sarah's 2023 salary in one formula

Multiple criteria with XLOOKUP(). Source: Image by Author.

This returns the value in column B for the row where column A is Sarah and column C is 2023. I cover more patterns in How to Use XLOOKUP() with Multiple Criteria in Excel.

Practical Examples and Use Cases

Let’s now take a look at some practical examples and use cases.

Using a lookup without having to re-arrange a table

I have a list of students' names and scores, and I want to find each student's score based on their name. For this purpose, I’ll use both XLOOKUP() and VLOOKUP() functions to show you the differences. 

When using XLOOKUP(), I enter the following formula:

=XLOOKUP(D8,B2:B5,A2:A5)

In this formula:

  • D8 contains the lookup value, Charlie.

  • B2:B5 range contains the student names. The XLOOKUP() function will search for the value in D8 within this range.

  • A2:A5 is the range that contains the scores corresponding to the student names. 

When using VLOOKUP(), I enter the following formula:

=VLOOKUP(D4,A1:B5,1,0)

In this formula:

  • D4 contains the lookup value, Charlie.

  • A1:B5 is the table array. Its first column is Scores, so VLOOKUP() looks for Charlie among the scores, not the names.

  • 1 returns the value from the 1st column of the range (Scores).

  • 0 retrieves the exact match.

VLOOKUP returns #N/A when the scores are left of the names, while XLOOKUP returns Charlie's score of 66

VLOOKUP() returns an #N/A error but XLOOKUP() handles it. Source: Image by Author.

As you can see, VLOOKUP() shows an #N/A error because it cannot search to the left.

Creating a custom output when a value is not found

I have a list of students with their IDs, names, and grades. While searching, I accidentally entered a student ID that was not on the list. To handle such a case, I want a customized message to appear whenever the student ID is not found. I’ll use both XLOOKUP() and VLOOKUP() functions to show you the differences. 

When using XLOOKUP(), I enter the following formula:

=XLOOKUP(E9, A2:A5, B2:B5, "Student not Found")

In this formula:

  • E9 contains the value we want to search for. In my case it's 14256.

  • A2:A5 is the cell range containing the look-up value (Student ID).

  • B2:B5 contains the scores to return.

  • Student not Found displays if the score is not on the list. 

When using VLOOKUP(), I enter the following formula:

=VLOOKUP(E6, A2:C5, 2, 0)

In this formula:

  • E6 refers to Student ID, which is what I’m searching for.

  • A2:C5 refers to the range which contains all the data in the table.

  • 2 indicates the column number from which the data will be fetched.

  • 0 retrieves the exact match.

For a student ID that isn't in the list, XLOOKUP returns Student not Found while VLOOKUP returns #N/A

XLOOKUP() returns a message but VLOOKUP() doesn’t. Source: Image by Author.

You can see 14256 does not exist in the range A2:A5, so XLOOKUP() returns the custom message Student not Found. And VLOOKUP(), on the other hand, throws an #N/A error. 

Searching from the bottom-up

I want to find Sarah's salary from the most recent year. For this purpose, I’ll use both XLOOKUP() and  VLOOKUP() functions to show you the differences. 

When using XLOOKUP(), I enter the following formula:

=XLOOKUP(F8,B2:B10,C2:C10,,,-1)

In this formula:

  • F8 contains the lookup value Sarah.

  • B2:B10 looks in the range and searches for Sarah. 

  • C2:C10 retrieves the data.

  • -1 searches from the bottom of the column. 

When using VLOOKUP(), I enter the following formula:

=VLOOKUP(F4, B2:C10,2,0)

In this formula:

  • F4 contains the lookup value Sarah.

  • B2:C10 searches for the lookup value within this range.

  • 2 indicates the column number Salary from which the data will be fetched.

  • 0 retrieves the exact match.

VLOOKUP returns Sarah's 2019 salary, while XLOOKUP searching from the bottom returns her most recent, from 2024

Difference between VLOOKUP() and XLOOKUP() in search mode. Source: Image by Author.

You can see XLOOKUP() finds the desired salary for the desired year, whereas VLOOKUP() only displays the first matched value. I was able to do this because XLOOKUP() allows me to search from the bottom up.

XLOOKUP() vs. INDEX()/MATCH()

Before XLOOKUP(), the standard fix for VLOOKUP()’s limits was combining INDEX() and MATCH(). It looks left, survives inserted columns, and works in every Excel version. XLOOKUP() does the same job with one function and three required arguments.

Here is the left lookup from the first example written both ways:

=XLOOKUP(D8, B2:B5, A2:A5)
=INDEX(A2:A5, MATCH(D8, B2:B5, 0))

INDEX()/MATCH() is still worth knowing for two jobs: files that must work in Excel 2019 or older, and two-way lookups that match a row and a column at once. XLOOKUP() can do a two-way lookup by nesting one XLOOKUP() inside another, but many people find the INDEX() version easier to read:

=INDEX(B2:E10, MATCH(G1, A2:A10, 0), MATCH(G2, B1:E1, 0))
=XLOOKUP(G2, B1:E1, XLOOKUP(G1, A2:A10, B2:E10))

For a full walkthrough, see INDEX MATCH in Excel.

Performance and Compatibility

Let’s now compare the performance and compatibility of both functions. 

Performance in large datasets

For exact matches, both functions scan the lookup column from top to bottom until they find a match, so on everyday workbooks you won’t notice a speed difference.

The gap opens on very large, sorted lists. XLOOKUP()’s binary search modes (search_mode 2 or -2) halve the search range at each step instead of checking every row, and they work with exact matches. VLOOKUP() only searches that way in approximate mode.

Compatibility with different versions of Excel

XLOOKUP() works in Microsoft 365, Excel 2021, Excel 2024, Excel for the web, and the Excel mobile apps. Google Sheets has its own XLOOKUP() with the same six arguments. It isn’t available in Excel 2019, Excel 2016, or earlier versions.

Someone who opens your workbook in one of those older versions sees the last calculated results, but editing or recalculating an XLOOKUP() formula returns a #NAME? error. If you share files with clients or other teams, check their Excel version first, or stick with VLOOKUP() or INDEX()/MATCH().

XLOOKUP() vs. VLOOKUP() Comparison Table

Here are the differences at a glance.

FeatureVLOOKUP()XLOOKUP()
Default Match ModeRequires specifying FALSE for an exact match.Defaults to exact match.
Lookup DirectionOnly searches to the right of the lookup column.Can search in any direction (left, right, top, bottom).
Array ReferencesRequires defining the entire data range and column index within a single formula.Allows separate arrays for the lookup value and return values.
Horizontal LookupDoes not support horizontal lookups (HLOOKUP() is required).Supports both vertical and horizontal lookups.
Handling Column ChangesAffected by column insertions/deletions due to hardcoded column indices.Unaffected by column changes, continuing to function without adjustments.
Approximate MatchNeeds the first column sorted in ascending order.Next smaller or next larger value, on unsorted data.
Custom Error MessagesDisplays #N/A error when no match is found.Allows customization of the output message when no match is found.
Return Multiple ValuesCan return only one value at a time.Can retrieve values from multiple columns simultaneously.
Multiple CriteriaNeeds a helper column.Multiply conditions inside one formula.
Search ModeSearches from top to bottom and returns the first match.Searches top-down or bottom-up, plus binary search on sorted data.
Performance in Large DatasetsSimilar to XLOOKUP() for exact matches.Similar for exact matches; binary search is faster on large sorted lists.
CompatibilityWorks with all versions of Excel.Microsoft 365, Excel 2021, Excel 2024, Excel for the web, and Google Sheets. Not Excel 2019 or older.
Best ForFiles opened in Excel 2019 or older.New formulas, left lookups, and tables whose columns change.

Common XLOOKUP() and VLOOKUP() Errors

Most lookup errors come from a missing match, a range of the wrong size, or a version mismatch. This table shows what each error means for each function.

ErrorVLOOKUP()XLOOKUP()
#N/ANo match found (or, in approximate mode, the lookup value is smaller than every value in the first column).No match found and no if_not_found value given.
#REF!col_index_num is larger than the number of columns in table_array.No column-number errors, because it references the return range directly.
#VALUE!col_index_num is less than 1.lookup_array and return_array are different sizes.
#NAME?A typo in the function name.A typo, or the file was edited in Excel 2019 or older.
#SPILL!Not applicable.A multi-column result is blocked by cells that already contain data.
Wrong value, no errorrange_lookup left out on unsorted data.Binary search used on unsorted data.

The last row is the one to watch, because nothing flags it. When you wrap VLOOKUP() to hide #N/A, prefer IFNA() over IFERROR(), so typos and #REF! errors still show up.

XLOOKUP returns #SPILL! when its result is blocked and #VALUE! when the lookup and return ranges differ in size

#SPILL! and #VALUE! errors in XLOOKUP(). Source: Image by Author.

XLOOKUP() or VLOOKUP(): Which Should You Use?

Your Excel version decides between XLOOKUP() and VLOOKUP()

Use XLOOKUP() for new formulas unless someone who opens the file is stuck on an older version. In practice:

  • Everyone has Microsoft 365, Excel 2021 or later, or works in Google Sheets: use XLOOKUP().
  • Anyone on Excel 2019 or older, including outside clients: use VLOOKUP() or INDEX()/MATCH().
  • An existing VLOOKUP() that works: there’s no need to rewrite it until you edit the sheet or its columns change.

It’s still worth learning both. VLOOKUP() has been around for decades, so you’ll keep meeting it in older workbooks. To convert many formulas at once, you can ask Copilot in Excel to rewrite the VLOOKUP() formulas on a sheet as XLOOKUP(). Check the proposed formulas before you accept them.

Final Thoughts

XLOOKUP() fixes the three things that make VLOOKUP() fragile: the approximate-match default, the right-only lookup, and the hardcoded column number. If everyone who opens your files has Microsoft 365, Excel 2021 or later, or Google Sheets, use it for new formulas. Keep VLOOKUP() for older workbooks and for colleagues on Excel 2019 or earlier.

If you're new to Excel or want to build a solid foundation, our Introduction to Excel course and the Excel Fundamentals skill track are great starting points for mastering the basics.

Laiba Siddiqui

Author

Laiba Siddiqui

I'm a content strategist who loves simplifying complex topics. I’ve helped companies like Splunk, Hackernoon, and Tiiny Host create engaging and informative content for their audiences.

Frequently Asked Questions

Is XLOOKUP() better than VLOOKUP()?

For most users, yes. XLOOKUP() defaults to an exact match, can return values from columns to the left of the lookup column, keeps working when you insert or delete columns, handles missing values with if_not_found, and can return several columns at once.

The exception is compatibility: XLOOKUP() isn’t available in Excel 2019 or older, so VLOOKUP() is the safer choice for files shared with people on those versions.

What are the limitations of VLOOKUP() compared to XLOOKUP()?

VLOOKUP() only searches the first column of the table array and can only return values to its right. It defaults to an approximate match, breaks when you insert or delete columns because of its hardcoded column number, has no built-in way to handle missing values, and returns one column per formula.

Can XLOOKUP() be used with SUM(), SUMIFS(), or COUNTIFS()?

Yes. XLOOKUP() returns a cell reference, not just a value, so you can use it inside other functions. For example, =SUM(XLOOKUP("Mar", A1:L1, A2:L2):XLOOKUP("Jun", A1:L1, A2:L2)) adds up the values from March to June. You can also use an XLOOKUP() result as a criterion inside SUMIFS() or COUNTIFS().

Does XLOOKUP() work in Google Sheets?

Yes. Google Sheets has an XLOOKUP() function with the same six arguments in the same order, including the match and search modes. See Excel vs. Google Sheets for other differences between the two.

What happens if I open a file with XLOOKUP() in Excel 2019?

You see the last calculated results, but XLOOKUP() isn’t available in Excel 2019 or earlier. If you edit the formula or the workbook recalculates it, the cell shows a #NAME? error, and any formulas that depend on it break too. Use VLOOKUP() or INDEX()/MATCH() for files shared with people on older versions.

Is XLOOKUP() faster than VLOOKUP()?

For exact matches on typical workbooks, the speed is similar, because both scan the lookup column row by row. XLOOKUP() can be much faster on very large lists sorted in order when you set search_mode to 2 or -2 for a binary search.

Should I still learn VLOOKUP()?

Yes. VLOOKUP() has been around for decades, so you’ll keep finding it in existing workbooks, and it’s the option that works for colleagues on older versions of Excel. Learn both, and use XLOOKUP() for new formulas when everyone who opens the file can run it.

Topics

Related

XLOOKUP(): Excel's Most Versatile Lookup Function

Tutorial

XLOOKUP(): Excel's Most Versatile Lookup Function

⌂ 换网址