Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST TOOLS

Excel Tutorial

Excel HOME Excel Introduction Excel Get Started Excel Overview Excel Syntax Excel Ranges Excel Fill Excel Move Cells Excel Add Cells Excel Delete Cells Excel Undo Redo Excel Formulas Excel Relative Reference Excel Absolute Reference Excel Arithmetic Operators Excel Parentheses Excel Functions

Excel Formatting

Excel Formatting Excel Format Painter Excel Format Colors Excel Format Fonts Excel Format Borders Excel Format Numbers Excel Format Grids Excel Format Settings

Excel Data Analysis

Excel Sort Excel Filter Excel Tables Excel Conditional Format Excel Highlight Cell Rules Excel Top Bottom Rules Excel Data Bars Excel Color Scales Excel Icon Sets Excel Manage Rules (CF) Excel Charts

Excel PivotTables

Excel PivotTable Intro Excel Create PivotTable Excel PivotTable Values Excel PivotTable Filter Excel PivotTable Group Excel Calculated Field Excel PivotChart

Excel Case

Case: Poke Mart Case: Poke Mart, Styling

Excel Functions

AND AVERAGE AVERAGEIF AVERAGEIFS CONCAT COUNT COUNTA COUNTBLANK COUNTIF COUNTIFS DATEDIF FILTER HLOOKUP IF IFERROR IFS INDEX INDEX MATCH LEFT LEN LOWER MATCH MAX MEDIAN MID MIN MODE NETWORKDAYS NPV OR PROPER RAND RIGHT ROUND SORT STDEV.P STDEV.S SUBSTITUTE SUM SUMIF SUMIFS SUMPRODUCT TEXTJOIN TODAY TRIM UNIQUE UPPER VLOOKUP XLOOKUP XOR

Excel How To

Convert Time to Seconds Difference Between Times NPV (Net Present Value) Remove Duplicates

Excel Cert

Excel Certificate

Excel Examples

Excel Exercises Excel Syllabus Excel Study Plan Excel Training

Excel References

Excel Keyboard Shortcuts


Excel XLOOKUP Function


Share

XLOOKUP Function

The XLOOKUP function is a premade function in Excel, which searches a range and returns the matching value from another range.

It is a newer and more flexible version of VLOOKUP. XLOOKUP can look to the left, and it uses exact match by default.

It is typed =XLOOKUP and has the following parts:

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

Note: XLOOKUP is available in Excel for Microsoft 365, Excel 2021, Excel 2024 and Excel for the web. It is not available in Excel 2019 or earlier. In those versions, use INDEX and MATCH instead.

Note: The different parts of the function are separated by a symbol, like comma , or semicolon ;

The symbol depends on your Language Settings.

Lookup_value: The value to search for. This is usually the cell where the search value is entered.

Lookup_array: The range to search in, for example one column.

Return_array: The range to return a value from. When you search a column, it must have the same number of rows as the lookup_array.

If_not_found: Optional. The value to show if no match is found. If you leave it out, XLOOKUP returns #N/A.

Match_mode: Optional. How the lookup_value is matched:

Match_modeDescription
0Exact match. This is the default.
-1Exact match. If none is found, the next smaller item.
1Exact match. If none is found, the next larger item.
2Wildcard match, where * and ? have a special meaning.

Search_mode: Optional. The direction of the search:

Search_modeDescription
1Search from first to last. This is the default.
-1Search from last to first.

There are also search modes 2 and -2, for searching data that is sorted. You will rarely need them.

How to use the XLOOKUP function:

  1. Select a cell (H4)
  2. Type =XLOOKUP
  3. Double click the XLOOKUP command
  4. Select the cell where the search value will be entered (H3)
  5. Type (,)
  6. Mark the range to search in (B2:B21)
  7. Type (,)
  8. Mark the range to return a value from (E2:E21)
  9. Hit enter
  10. Enter a value in the search cell (H3)

Let's have a look at an example!

This is the same Pokemon table as on the VLOOKUP page. Copy it and paste it into cell A1 to follow along:

Example data

ABCDE
1ID#NameType 1Type 2Total
21BulbasaurGrassPoison318
32IvysaurGrassPoison405
43VenusaurGrassPoison525
54CharmanderFire309
65CharmeleonFire405
76CharizardFireFlying534
87SquirtleWater314
98WartortleWater405
109BlastoiseWater530
1110CaterpieBug195
1211MetapodBug205
1312ButterfreeBugFlying395
1413WeedleBugPoison195
1514KakunaBugPoison205
1615BeedrillBugPoison395
1716PidgeyNormalFlying251
1817PidgeottoNormalFlying349
1918PidgeotNormalFlying479
2019RattataNormal253
2120RaticateNormal413

Type the labels Search Name in G3 and Total in G4.

Use the XLOOKUP function to find the Total of a Pokemon based on its Name. Type Squirtle in H3:

ABCDEFGH
1ID#NameType 1Type 2Total
21BulbasaurGrassPoison318
32IvysaurGrassPoison405Search NameSquirtle
43VenusaurGrassPoison525Total314
54CharmanderFire309
65CharmeleonFire405
76CharizardFireFlying534
87SquirtleWater314
98WartortleWater405
109BlastoiseWater530
1110CaterpieBug195
1211MetapodBug205
1312ButterfreeBugFlying395
1413WeedleBugPoison195
1514KakunaBugPoison205
1615BeedrillBugPoison395
1716PidgeyNormalFlying251
1817PidgeottoNormalFlying349
1918PidgeotNormalFlying479
2019RattataNormal253
2120RaticateNormal413
=XLOOKUP(H3, B2:B21, E2:E21)

XLOOKUP searches B2:B21 for Squirtle and finds it in row 8. It returns the value from the same row in E2:E21, which is 314.

There is no column number to count, and no range_lookup to set. Exact match is the default.

Try another name in H3, like Blastoise. The result changes to 530.



XLOOKUP to the Left

VLOOKUP can only return values from columns to the right of the search column. XLOOKUP can return values from any column, also columns to the left.

Find the ID# of a Pokemon based on its Name. The ID# column (A) is to the left of the Name column (B).

Change the label in G4 to ID#, and type Pidgeotto in H3:

GH
3Search NamePidgeotto
4ID#17
=XLOOKUP(H3, B2:B21, A2:A21)

XLOOKUP finds Pidgeotto in B18 and returns 17 from A18. VLOOKUP cannot do this.


If Not Found

If XLOOKUP does not find the value, it returns #N/A. Use the if_not_found part to show your own message instead.

Pikachu is not in the table. Change G4 back to Total, and type Pikachu in H3:

GH
3Search NamePikachu
4TotalNot found
=XLOOKUP(H3, B2:B21, E2:E21, "Not found")

Without "Not found", the result would be #N/A.

Note: Text in a formula must be inside double quotes: " "


Return Several Columns

The return_array can be more than one column wide. Then XLOOKUP returns several values at once, and they spill into the cells to the right.

Return Type 1, Type 2 and Total for Charizard with one formula. Change G4 to Types and Total, and type Charizard in H3:

GHIJ
3Search NameCharizard
4Types and TotalFireFlying534
=XLOOKUP(H3, B2:B21, C2:E21)

The formula is typed only in H4. The return_array C2:E21 is three columns wide, so the result spills into H4:J4.

Note: The cells that the result spills into must be empty. If they are not, XLOOKUP returns a #SPILL! error.

Now type Squirtle in H3. Squirtle has no Type 2:

GHIJ
3Search NameSquirtle
4Types and TotalWater0314

Note: When the matching cell is empty, XLOOKUP returns 0, not an empty cell. That is why I4 shows 0 for Squirtle. Keep this in mind when a column has empty cells.


Search From the Bottom

By default, XLOOKUP searches from the first row to the last, and returns the first match. Set search_mode to -1 to search from the last row up, and get the last match instead.

Find the first and the last Bug Pokemon in the table. Type the labels Search Type in G3, First in G4 and Last in G5. Then type Bug in H3:

GH
3Search TypeBug
4FirstCaterpie
5LastBeedrill

The formula in H4 searches from the top:

=XLOOKUP(H3, C2:C21, B2:B21)

The formula in H5 searches from the bottom:

=XLOOKUP(H3, C2:C21, B2:B21, "Not found", 0, -1)

The first Bug Pokemon is Caterpie (ID# 10). The last one is Beedrill (ID# 15).

To set search_mode, you must also fill in the parts before it. Here, if_not_found is "Not found" and match_mode is 0 (exact match).


VLOOKUP vs XLOOKUP

VLOOKUPXLOOKUP
Look to the leftNoYes
Default matchApproximate (when range_lookup is left out)Exact
The return column is set byA column numberA range
Inserting a column in the tableCan break the resultAdjusts automatically
Own message when nothing is foundNoYes, with if_not_found
Search from the bottomNoYes, with search_mode
Horizontal lookupsNo, use HLOOKUPYes
Excel versionsAll versionsMicrosoft 365, Excel 2021, Excel 2024 and Excel for the web

If everyone who uses your file has Excel for Microsoft 365 or Excel 2021 or newer, XLOOKUP is usually the easier choice. For older versions, use VLOOKUP or INDEX and MATCH.


Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.