Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Analysis and Reporting with Excel  ›  Lesson

VLOOKUP and HLOOKUP

VLOOKUP / HLOOKUP 15 minVLOOKUP finds a key in the first column of a table and returns a value from a chosen column in the same row; HLOOKUP does the same across rows.

VLOOKUP and HLOOKUP

The orders sheet stores item codes like C01, but Nisha's report must say "Cold coffee". The names and prices live on a separate Menu sheet. Copying them across by hand would break the moment a price changes. A lookup formula fetches the right value for each row, and updates itself when the menu does.

The Menu sheet:

A B C
1 code item price
2 C01 Cold coffee 120
3 C02 Masala chai 40
4 B01 Banana bread 90
5 B02 Croissant 110

The rule

Find the key in the first column, return column N of that row.

=VLOOKUP(D2, Menu!$A$2:$C$5, 2, FALSE)
  • D2: the key to look for, here the order's item code.
  • Menu!$A$2:$C$5: the table. VLOOKUP only ever searches its first column. The dollar signs lock the range so it does not slide as you copy down.
  • 2: which column of the table to return, counting the first column as 1. Column 2 is item; column 3 would be price.
  • FALSE: exact match only. Always use it for codes, IDs and names.

If the key is not in the first column, the result is #N/A. Treat that as a data-quality flag: a typo, a stray space, or a new item missing from the menu.

HLOOKUP is the same idea turned on its side. It searches the top row of a table and returns row N, counting down from the top. Use it when your keys run across a row, such as months in a header: =HLOOKUP("Mar", A1:M3, 3, FALSE) finds "Mar" in row 1 and returns the value from the table's third row.

Newer versions of Excel also have XLOOKUP, which can search any column and return from any other. VLOOKUP is still everywhere in existing workbooks, so you must be able to read it.

The shortcut

Say the formula as a sentence: "Find this in the first column, move to column N, exactly." If the column you want to search is not the first one in the range, VLOOKUP cannot do it.

Looking up order 1004 (item code B02)Step 1 of 4
  1. Find the key

    Search column A of the Menu table for B02. It is in the fourth row of the table (sheet row 5).

The trap is leaving out the last argument. Without FALSE, VLOOKUP assumes the first column is sorted and may quietly return a neighbouring row instead of an error.

Drills

Answer fast — trust the rule.

quick drill

What does =VLOOKUP("C02", Menu!$A$2:$C$5, 3, FALSE) return?

quick drill

Order 1003 has item code B01. Which formula returns its name?

quick drill

A lookup for "C01 " (with a trailing space) returns #N/A. Why?

quick drill

You want the price for "Banana bread" by searching the item column. Why does =VLOOKUP("Banana bread", Menu!$A$2:$C$5, 3, FALSE) fail?

quick drill

Monthly totals sit in a table with months across row 1 and totals in row 2. Which function fits?

Remember

  • Find the key in the first column, return column N of that row.
  • Shortcut: read it as "find this, move to column N, exactly"; HLOOKUP searches the top row and returns row N.
  • Trap: leaving out FALSE, and expecting VLOOKUP to search any column but the first.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainBring the item names across

The orders sheet has item codes in D2:D6 and the menu sheet has code, item and price in A2:C5. Write a VLOOKUP that shows the item name next to each order, explain each argument, and say what an #N/A result tells you.