What is the VLOOKUP function?
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])VLOOKUP looks for a value in the first column of a table and returns the value from another column in the same row. The V stands for vertical: it searches down the first column from top to bottom.
Use it whenever you need "the value that goes with this one": a price for a product code, a name for an employee ID, a grade for a score.
The one rule to remember is that VLOOKUP only ever searches the first column of table_array. Drag the top-left handle of the range in the sheet above to move its first column, and watch the same lookup value give a different result.
Arguments
- lookup_value
- The value to find in the first column of table_array. Type it directly, like "P004", or point to a cell such as F2. Text matching is not case-sensitive.
- table_array
- The table to search. The column that contains lookup_value must be the first column of this range, and the column you want to return must also be inside it.
- col_index_num
- The position of the column to return, counted inside table_array. It is not the sheet column letter: if table_array starts at column B, then B is 1 and C is 2.
- range_lookup
- FALSE returns only an exact match. TRUE returns the largest value that is less than or equal to lookup_value, and needs the first column sorted in ascending order. If you leave it out, VLOOKUP uses TRUE, so type FALSE whenever you need an exact match.
VLOOKUP examples
Example 1. Find a price by product code
=VLOOKUP("P004", A2:D9, 3, FALSE)Finds P004 in column A and returns the 3rd column of the range (Price). The result is 6900. This is the formula the sheet above starts with.
Example 2. Use a cell as the lookup value
=VLOOKUP(F2, $A$2:$D$9, 2, FALSE)With P006 in F2, the result is Noodles. Pointing to a cell lets you change the code without editing the formula. Lock table_array with $ so it doesn't shift when you copy the formula down.
Example 3. Assign grades with approximate match
=VLOOKUP(85, A2:B6, 2, TRUE)List the starting score of each band in ascending order. There is no 85, so VLOOKUP takes 80, the largest value below 85, and returns B. Use the same pattern for tiered rates, commissions or shipping fees.
Score (from) Grade 0 F 60 D 70 C 80 B 90 A
Common mistakes
The lookup column is not the first column
If you search by product name but table_array starts at the code column, you get #N/A. Start table_array at the column that contains lookup_value. VLOOKUP cannot return values to the left of that column; use XLOOKUP or INDEX/MATCH for that.
range_lookup was left out
Without the fourth argument VLOOKUP uses approximate match (TRUE). If the first column isn't sorted, it can return a wrong value without any error, which is hard to notice.
Counting sheet columns instead of table columns
If table_array is B2:D9, column D is 3, not 4. A col_index_num larger than the table width gives #REF!, and less than 1 gives #VALUE!.
Numbers stored as text
The number 1500 and the text "1500" look the same but are different values, so the lookup returns #N/A. This often happens with data imported from other systems.
Extra spaces
"P004 " with a trailing space is a different value from "P004". Clean the data with TRIM before looking it up.
FAQ
- Why does VLOOKUP return #N/A when the value is clearly there?
- Usually the value is not in the first column of table_array, there are hidden spaces, or one side is a number and the other is text.
- Can VLOOKUP return a value to the left?
- No. It only returns columns to the right of the first column. Use XLOOKUP, or INDEX with MATCH.
- Should I use TRUE or FALSE?
- Use FALSE for codes, names and IDs. Use TRUE only for bands like score ranges, with the first column sorted in ascending order.