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 beprice. - 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.