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 HLOOKUP Function


Share

HLOOKUP Function

The HLOOKUP function is a premade function in Excel, which searches the top row of a table and returns a value from a row below it.

HLOOKUP is the horizontal version of VLOOKUP. VLOOKUP searches down the first column of a table. HLOOKUP searches across the top row.

It is typed =HLOOKUP and has the following parts:

=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])

Note: The row which holds the data used to lookup must always be the top row of the table.

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.

Table_array: The table range. HLOOKUP searches the top row of this range.

Row_index_num: The row to return a value from, counted from the top of the table range. The top row is row 1.

Range_lookup: Optional. FALSE (0) for an exact match, or TRUE (1) for an approximate match. Approximate match needs the top row sorted from smallest to largest. If you leave it out, TRUE is used.

Tip: Use FALSE (0) when you look up names or items, like in the example below. It finds the exact value, and it works whether the data is sorted or not.

How to use the HLOOKUP function:

  1. Select a cell (B6)
  2. Type =HLOOKUP
  3. Double click the HLOOKUP command
  4. Select the cell where the search value will be entered (B5)
  5. Type (,)
  6. Mark the table range (B1:H3)
  7. Type (,)
  8. Type the number of the row, counted from the top (2)
  9. Type (,)
  10. Type FALSE for an exact match
  11. Hit enter
  12. Enter a value in the search cell (B5)

Let's have a look at an example!

Here is a price list from the Poke Mart. The items are in the top row, with their price and category in the rows below. Copy it and paste it into cell A1 to follow along:

Example data

ABCDEFGH
1ItemPoke BallGreat BallUltra BallPotionSuper PotionHyper PotionRevive
2Price200600120030070012001500
3CategoryBallsBallsBallsMedicineMedicineMedicineMedicine

Type the labels Search Item in A5 and Price in A6.

Use the HLOOKUP function to find the Price of an item. Type Ultra Ball in B5:

ABCDEFGH
1ItemPoke BallGreat BallUltra BallPotionSuper PotionHyper PotionRevive
2Price200600120030070012001500
3CategoryBallsBallsBallsMedicineMedicineMedicineMedicine
4
5Search ItemUltra Ball
6Price1200
=HLOOKUP(B5, B1:H3, 2, FALSE)

HLOOKUP searches the top row of B1:H3 for Ultra Ball, and finds it in column D. Row 2 of the table holds the prices, so it returns 1200 from D2.

Column A only holds the labels, so it is left out of the table range.



Return a Different Row

Change row_index_num to return a different row. Row 3 of the table holds the category.

Type the label Category in A7, and the formula below in B7. Then type Revive in B5:

AB
5Search ItemRevive
6Price1500
7CategoryMedicine
=HLOOKUP(B5, B1:H3, 3, FALSE)

Revive costs 1500, and it is in the Medicine category.


When There is No Match

With FALSE, HLOOKUP returns #N/A when the value is not in the top row. The price list has no Max Potion:

AB
5Search ItemMax Potion
6Price#N/A
=HLOOKUP(B5, B1:H3, 2, FALSE)

With TRUE, HLOOKUP looks for an approximate match instead. The top row here is not sorted, so it could return the price of the wrong item, without any error.


HLOOKUP or XLOOKUP?

The XLOOKUP function also works horizontally. Give it the row to search in, and the row to return a value from:

=XLOOKUP(B5, B1:H1, B2:H2)

With Ultra Ball in B5, this also returns 1200. XLOOKUP needs no row number, and it uses exact match by default.

Note: XLOOKUP is only available in Excel for Microsoft 365, Excel 2021, Excel 2024 and Excel for the web.

In older versions, use HLOOKUP, or INDEX and MATCH:

=INDEX(B2:H2, MATCH(B5, B1:H1, 0))

This also returns 1200 for Ultra Ball.


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.