Skip to main content
HomeTutorialsExcel

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.
Aug 2024  · 11 min read

For decades, VLOOKUP() has been Excel's go-to function for data lookup. It’s a reliable tool but has limitations. That’s why in 2019, XLOOKUP(), a new function with advanced capabilities, was introduced. In this article, we’ll compare VLOOKUP() versus XLOOKUP() to better understand their features and different uses. 

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 out Excel Fundamentals skill track to make sure you are using the latest features.

Advance Your Career with Excel

Gain the skills to maximize Excel—no experience required.

Start Today for Free

XLOOKUP() and VLOOKUP() Syntax

Now that you have a basic understanding of both functions, let’s understand their syntax and how to use them in real-life applications. 

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 should contain the search_key.

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

  • range_lookup is where you enter a logical value (TRUE or FALSE).

Syntax of XLOOKUP()

Let’s now take a look at the xlookup() syntax. As we can see, XLOOKUP() has more arguments than VLOOKUP().

=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 is used to perform binary search in ascending order. -2 is used to perform binary search in descending order.

Main Differences: XLOOKUP() vs. VLOOKUP()

Let’s now explore some key differences between the XLOOKUP() and VLOOKUP() functions.

Exact match mode 

XLOOKUP() defaults to exact match mode but VLOOKUP() requires specifying FALSE for an exact match.

XLOOKUP defaults to exact match, while VLOOKUP requires specifying FALSE for exact match.

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

In VLOOKUP(), I didn't specify the range_lookup value (4th argument), so it gave the closest match, which is not our desired result. XLOOKUP(), on the other hand, returns the exact match by default.

Lookup direction

VLOOKUP() is restricted to searching only to the right of the first column in the selected table array. But XLOOKUP() can search for values in any direction.

VLOOKUP can only search to the right of the lookup column, while XLOOKUP can search both left and right within the lookup array.

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 needs a single data range and column index, while XLOOKUP allows separate arrays for lookup and return values.

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.

Handling horizontal rows with VLOOKUP, HLOOKUP, XLOOKUP

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

Handling column insertions/deletions 

The column changes affect VLOOKUP() because of the hardcoded column_index_num. However, XLOOKUP() isn't affected by column changes. It continues functioning without adjustments to the formula.

XLOOKUP remains unaffected by column changes, while VLOOKUP fails due to hardcoded column indices."

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

Sorting and searching

You can sort VLOOKUP() in ascending order, but this would lead to difficulties when dealing with unsorted data. However, XLOOKUP() can use the search_mode argument to search in both ascending and descending order.

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

Handling Insertion/deletion in XLOOKUP() and VLOOKUP(). Source: Image by Author.

Custom error messages

VLOOKUP() shows an #N/A error sign when no match is found. XLOOKUP() has an optional if_not_found parameter that lets you customize the output text if a value is not found. 

XLOOKUP can return a custom message when a value isn't found, whereas VLOOKUP shows an #N/A error.

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. That’s why you can use one XLOOKUP() formula instead of multiple VLOOKUP() formulas.

XLOOKUP retrieves multiple columns, while VLOOKUP can only fetch a single column

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. But XLOOKUP() can scan a list in either direction (top-down or bottom-up) and find things quickly in extensive lists.

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.

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 look up value which is 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 look up value which is Charlie.

  • A1:B5 range searches within all the columns (Scores, Student Name).

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

  • 0 retrieves the exact match.

VLOOKUP returns an #N/A error for left lookups, while XLOOKUP handles it perfectly.

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 searches for the score of the ID 14526.

  • 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 am 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.

XLOOKUP returns custom message while VLOOKUP shows #N/A error

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 the first match from the top of the list, while XLOOKUP can search in both directions and find the most recent match

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 form the bottom-up.

Performance and Compatibility

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

Performance in large datasets

VLOOKUP() can be slower when dealing with large datasets, especially if the lookup column is not sorted and the range lookup argument is set to FALSE for an exact match. This is because VLOOKUP() scans the dataset sequentially until it finds a match, which can be time-consuming for large tables. XLOOKUP() offers better performance with large datasets. It can handle exact matches more efficiently and search horizontally and vertically without sorting. 

Compatibility with different versions of Excel

Now, you must be thinking of ditching VLOOKUP() after seeing the benefits of XLOOKUP(). But let me clarify—although XLOOKUP() is a much faster and excellent feature, there are a couple of times when it’s unavailable. This is because XLOOKUP() is a newer feature that only works in Excel 2021 and Microsoft 365 (from 2019). If you collaborate with people using older versions of Excel, you’ll need to use VLOOKUP() and other functions instead of XLOOKUP().

Summary table

Let's create a summary table for easy reference. 

Feature VLOOKUP() XLOOKUP()
Default Match Mode Requires specifying FALSE for an exact match. Defaults to exact match.
Lookup Direction Only searches to the right of the lookup column. Can search in any direction (left, right, top, bottom).
Array References Requires defining the entire data range and column index within a single formula. Allows separate arrays for the lookup value and return values.
Horizontal Lookup Does not support horizontal lookups (HLOOKUP() is required). Supports both vertical and horizontal lookups.
Handling Column Changes Affected by column insertions/deletions due to hardcoded column indices. Unaffected by column changes, continuing to function without adjustments.
Sorting and Searching Limited to sorting in ascending order. Can search in both ascending and descending order using the search_mode argument.
Custom Error Messages Displays #N/A error when no match is found. Allows customization of the output message when no match is found.
Return Multiple Values Can return only one value at a time. Can retrieve values from multiple columns simultaneously.
Search Mode Searches from top to bottom and returns the first match. Can search in both directions (top-down or bottom-up) for faster results in extensive lists.
Performance in Large Datasets Can be slower, especially with unsorted data or when range_lookup is FALSE. Better performance, handles large datasets efficiently, and searches without sorting.
Compatibility Works with all versions of Excel. Only available in Excel 2021 and Microsoft 365 (from 2019).
Final Thoughts Still useful for older Excel versions or simpler lookup tasks. More powerful and flexible, better suited for complex or large-scale lookups.

Final Thoughts

XLOOKUP() outperforms VLOOKUP(), especially when handling large datasets or complex lookup requirements. Its flexibility, including bidirectional search, multiple result retrieval, and adaptability to data changes, makes it a helpful tool. However, VLOOKUP() still holds its place, particularly for users of older Excel versions or those preferring a simpler approach to basic lookups. The best choice ultimately depends on your specific needs and Excel version.

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.

Learn Excel Fundamentals

Gain skills to use Excel effectively—no experience required.

Photo of Laiba Siddiqui
Author
Laiba Siddiqui
LinkedIn
Twitter

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()?

Yes, XLOOKUP() is better because it can search in any column within a table, return multiple results, handle errors better, and perform both vertical and horizontal lookups.

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

VLOOKUP() is limited to searching in the first column of a specified range. And it can only return one result per lookup.

Can XLOOKUP() handle array operations like SUMIFS() or COUNTIFS()?

Yes, XLOOKUP() can be used with array functions like SUMIFS() and COUNTIFS() to perform more complex calculations and data analysis tasks.

Topics

Learn Excel with DataCamp

Course

Financial Modeling in Excel

3 hr
7.1K
Learn about Excel financial modeling, including cash flow, scenario analysis, time value, and capital budgeting.
See DetailsRight Arrow
Start Course
See MoreRight Arrow
Related

tutorial

Data Wrangling with VLOOKUP in Spreadsheets

In this tutorial, you will get an overview of how to use the VLOOKUP function and also a basic explanation of INDEX-MATCH.
Francisco Javier Carrera Arias's photo

Francisco Javier Carrera Arias

11 min

tutorial

How to Use the XLOOKUP Excel Function with Multiple Criteria

This tutorial discusses the purpose and syntax of the XLOOKUP Excel function, its advantages concerning its predecessors, the two main ways of using XLOOKUP with multiple criteria including their pros and cons, extending functionality through the optional parameters, and the way of running a similar search in older Excel versions.
Elena Kosourova's photo

Elena Kosourova

0 min

tutorial

How to Combine VLOOKUP() with IF() in Excel

Combine VLOOKUP() with IF() for efficient data analysis, including conditional lookups, error handling, and dynamic column indexing.
Laiba Siddiqui's photo

Laiba Siddiqui

10 min

tutorial

How to Do a VLOOKUP() with Multiple Criteria

Master the art of using VLOOKUP() with multiple criteria in Excel. Explore advanced techniques like helper columns and the CHOOSE() function.
Laiba Siddiqui's photo

Laiba Siddiqui

10 min

tutorial

How to Use HLOOKUP in Excel

A beginner-friendly, comprehensive tutorial in mastering the HLOOKUP function in Microsoft Excel.
Arunn Thevapalan's photo

Arunn Thevapalan

6 min

tutorial

How to Compare Two Columns in Excel: A Step-by-Step Guide

Learn how to compare two columns in Excel for matches and for duplicates using methods like the equals operator, IF() function, EXACT(), VLOOKUP(), and more.
Laiba Siddiqui's photo

Laiba Siddiqui

9 min

See MoreSee More