Table of Contents
Basic Syntax of XLOOKUP
1. Simple Exact Match Lookup
2. Handle Missing Values with a Custom Message
3. Use Wildcards for Partial Matches
4. Search from Bottom to Top
5. Two-Way Lookup (Rows and Columns)
Key Advantages Over VLOOKUP
Home Software Tutorial Office Software How to use the XLOOKUP function in Excel?

How to use the XLOOKUP function in Excel?

Aug 03, 2025 am 04:39 AM

XLOOKUP is a modern function in Excel that replaces old functions such as VLOOKUP. 1. The basic syntax is XLOOKUP (find value, find array, return array, [value not found], [match pattern], [search pattern]); 2. Accurate search can be achieved, such as =XLOOKUP("P002", A2:A4, B2:B4) returns 15.49; 3. Customize the prompt when not found through the fourth parameter, such as "Product not found"; 4. Set the matching pattern to 2. Use wildcards to perform fuzzy search, such as "Joh*" to match names starting with John; 5. Set the search pattern to -1 and search from behind to front to return the last match; 6. Nesting two XLOOKUPs It can realize two-way searches, such as positioning data based on row and column titles; compared with VLOOKUP, it does not require column indexing, can look up to the left, defaults to precise matching, and is more suitable for structural changes. It is suitable for Excel 365 and newer versions, making data searches more efficient and accurate.

How to use the XLOOKUP function in Excel?

The XLOOKUP function in Excel is a modern, flexible replacement for older lookup functions like VLOOKUP, HLOOKUP, and INDEX/MATCH. It's easier to use and more powerful. Here's how to use it effectively.

How to use the XLOOKUP function in Excel?

Basic Syntax of XLOOKUP

The general structure of the XLOOKUP function is:

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

Let's break down each argument:

How to use the XLOOKUP function in Excel?
  • lookup_value : The value you want to search for (eg, a product ID or name).
  • lookup_array : The range or array where Excel should look for the lookup_value (eg, a column of IDs).
  • return_array : The range or array from which to return a value (eg, a column of prices).
  • [if_not_found] (optional): What to return if no match is found (eg, "Not Found").
  • [match_mode] (optional): How to match (0 = exact match, -1 = exact or next smaller, 1 = exact or next larger, 2 = wildcard).
  • [search_mode] (optional): How to search (1 = first to last, -1 = last to first, 2 = binary ascending, -2 = binary descending).

1. Simple Exact Match Lookup

Suppose you have a table with product IDs in column A and prices in column B:

A B
P001 10.99
P002 15.49
P003 8.99

To find the price for product ID "P002":

How to use the XLOOKUP function in Excel?
 =XLOOKUP("P002", A2:A4, B2:B4)

This returns 15.49 .

You can also reference a cell instead of typing the value:

 =XLOOKUP(D2, A2:A4, B2:B4)

Where D2 contains "P002".


2. Handle Missing Values with a Custom Message

If the lookup value might not exist, use the fourth argument to avoid #N/A errors.

 =XLOOKUP("P005", A2:A4, B2:B4, "Product not found")

This returns "Product not found" instead of an error.


3. Use Wildcards for Partial Matches

With match_mode = 2 , you can use wildcards like * and ? .

Example: Find a name that starts with "Joh":

 =XLOOKUP("Joh*", A2:A10, B2:B10, "Not found", 2)

This matches "John", "Johnny", etc.


4. Search from Bottom to Top

By default, XLOOKUP finds the first match from top to bottom. To find the last match, set search_mode = -1 .

Example: Find the last occurrence of "Apple" in a list:

 =XLOOKUP("Apple", A2:A10, B2:B10, "Not found", 0, -1)

This is useful when dealing with duplicate entries and you want the most recent one.


5. Two-Way Lookup (Rows and Columns)

You can combine two XLOOKUPs to look up data based on both row and column values.

Suppose you have a table with products in rows and months in columns:

B C D
1 Jan Feb
2 P001 100 120
3 P002 80 90

To get the sales for P001 in Feb:

 =XLOOKUP("P001", A2:A3, XLOOKUP("Feb", B1:D1, B2:D3))

This first finds the "Feb" column, then looks up "P001" in that column.


Key Advantages Over VLOOKUP

  • No need to count columns (no column index number).
  • Can look to the left (unlike VLOOKUP).
  • Safer defaults (exact match by default).
  • Handles insert/delete of columns better.
  • Supports advanced options like reverse search and wildcards.

XLOOKUP works in Excel 365 and Excel 2021 or later. If you're using an older version, consider upgrading or using INDEX/MATCH instead.

Basically, once you get used to it, XLOOKUP makes finding data faster and less error-prone.

The above is the detailed content of How to use the XLOOKUP function in Excel?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1585
276
How to get the last value in a column in Excel How to get the last value in a column in Excel Jul 26, 2025 am 08:03 AM

To obtain the last value of a column in Excel, you can choose different methods according to the data characteristics: 1. Use the LOOKUP function to quickly find the last non-null value, which is suitable for situations where there may be empty rows in the data. The formula is =LOOKUP(2,1/(A:A""), A:A); 2. Use the INDEX COUNTA combination to process continuous data, which is suitable for data columns without empty rows, and the formula is =INDEX(A:A,COUNTA(A:A)); 3. Use the INDEX MATCH combination to obtain the last numeric value, which is suitable for data columns containing only numbers, and the formula is =INDEX(A:A,MATCH(9.99E 307,A:A)). this

How to use the XLOOKUP function in Excel? How to use the XLOOKUP function in Excel? Aug 03, 2025 am 04:39 AM

XLOOKUP is a modern function used in Excel to replace old functions such as VLOOKUP. 1. The basic syntax is XLOOKUP (find value, search array, return array, [value not found], [match pattern], [search pattern]); 2. Accurate search can be realized, such as =XLOOKUP("P002", A2:A4, B2:B4) returns 15.49; 3. Customize the prompt when not found through the fourth parameter, such as "Productnotfound"; 4. Set the matching pattern to 2, and use wildcards to perform fuzzy search, such as "Joh*" to match names starting with Joh; 5. Set the search mode

how to add different headers and footers in word how to add different headers and footers in word Jul 26, 2025 am 04:17 AM

To set different headers and footers in Word, you must first insert the section break character. 1. Click the starting position of the new section, 2. Select "Next Page" or "Continuous" in the "Delimiter" in "Layout", 3. After inserting, double-click the header footer area, cancel "Link to Previous" to disconnect the link, so that each section can be set independently; if it cannot be modified, it may be that the link is not cancelled or the section break character is deleted by mistake, you can set the cover page to "None" header footer, and hide it by setting the height to 0 or enabling "Different Home Page".

How to start a Word document How to start a Word document Jul 26, 2025 am 12:36 AM

Microsoft Word is the go-to tool for word processing across the globe. Whether you're a student drafting an essay or a professional preparing business reports, Word provides all the tools you need. But every project starts with one essential step—cre

How To Fix the 'PUR-AuthenticationFailure' Error in Microsoft Store How To Fix the 'PUR-AuthenticationFailure' Error in Microsoft Store Jul 25, 2025 am 01:41 AM

Why does the directory experience "PUR-AuthenticationFailure" error? Resolve the "PUR-authentication failed" error check in the Windows Store and correct the system date and time settings. Reset Microsoft Store and its components. Disable proxy settings. Temporarily turn off the antivirus software. Enable the Microsoft Account Login Assistant service. Switch to other user accounts. Conclusion Why does the "PUR-AuthenticationFailure" error appear? "PUR authentication failed" errors can be caused by a variety of factors, including: Incorrect date and time of the system, Windows Store components are outdated or damaged

How to insert a PDF into an Excel sheet How to insert a PDF into an Excel sheet Jul 30, 2025 am 04:09 AM

There are three main ways to insert PDF into Excel. First, insert PDF as an object, click "Insert" → "Object" → "Create from File", select PDF file and optionally link to the file, which is suitable for embedding the entire file; second, convert PDF into picture and insert the image, and use the tool to export the image and add it through "Insert" → "Image", which is suitable for displaying content but is not convenient for multi-page processing; third, insert hyperlinks, right-click the cell to set the hyperlink to point to the PDF file, which is suitable for providing access paths. Different methods are suitable for different scenarios, just choose as needed.

How to add transitions between slides in a PPT? How to add transitions between slides in a PPT? Aug 11, 2025 pm 03:31 PM

Open the "Switch" tab in PowerPoint to access all switching effects; 2. Select switching effects such as fade in, push, erase, etc. from the library and click Apply to the current slide; 3. You can choose to keep the effect only or click "All Apps" to unify all slides; 4. Adjust the direction through "Effect Options", set the speed of "Duration", and add sound effects to fine control; 5. Click "Preview" to view the actual effect; it is recommended to keep the switching effect concise and consistent, avoid distraction, and ensure that it enhances rather than weakens information communication, and ultimately achieve a smooth transition between slides.

how to customize the ribbon in word how to customize the ribbon in word Aug 01, 2025 am 06:20 AM

To customize the Word ribbon, first right-click the ribbon to select "Custom Ribbon" or enter the settings interface through "File" > "Options" > "Custom Ribbon"; then select common functions from the command list on the left, click "New Tab" or select an existing tab and use the "Add" button to add it to the layout on the right, and drag the order to adjust it; then create exclusive tabs and groups, such as "Writing Tools" and rename them to improve recognition; finally pay attention to saving changes, and understand that custom settings are saved based on document templates, and you can reset and restore the default layout at any time.

See all articles