The Excel VLOOKUP Function

Basic Description

The Excel VLOOKUP function 'looks up' a given value in the left-hand column of a data array (or table), and returns the corresponding value from another column of the array.

The syntax of the function is:

VLOOKUP( lookup_value, table_array, col_index_num, [range_lookup] )

where the arguments are as follows:

lookup_value-The value that you want to look up.
table_array-The data array or table, containing the search values in the left hand columns and the values to return in another column.
col_index_num-The column number, within the supplied table_array, that you want to return a value from.
[range_lookup]-

An optional logical argument, that describes what the function should return in the event that it does not find an exact match to the lookup_value.

The [range_lookup] can be set to TRUE or FALSE, meaning:
TRUE-

If the function cannot find an exact match to the supplied lookup_value, it should use the closest match below the supplied value.

Note: if this option is used, the left-hand column of the table_array must be in ascending order.

FALSE-If the function cannot find an exact match to the supplied lookup_value, it should return an error.


Wildcards

In text-related Vlookups, where an exact match is required, the lookup_value can contain the following wildcard characters:

?    -    matches any single character

*    -    matches any sequence of characters

Vlookup Examples

Example 1 - Vlookup Requiring an Exact Match

In the spreadsheet below, columns A and B list an inventory of grocery items, and their prices, and cell E2 of the spreadsheet shows a simple example of the Vlookup function being used to look up the price of an item from the inventory.

 ABCDE 
1Item DescriptionCost ($) Current Item:Current Item Cost ($) 
2Tinned Tomatoes$0.90 Cornflakes =VLOOKUP( D2, A:B, 2, FALSE ) - returns the value $3.50
3Tinned Tuna$1.50    
4Cornflakes$3.50    
5Shortcake Biscuits$1.00    
6Toothpaste$4.10    
7Tinned Baked Beans$0.99    
8White Sliced Bread$0.80    
9      .
      .
      .
.    
.    
.    
    

The above Vlookup function returns the price for "Cornflakes", which is $3.50.

In this example:


Example 2 - Vlookup Requiring the Closest Match

In the spreadsheet below, columns A-C list the grades that are assigned to examination marks lying within the ranges 0-44%, 45%-54%, etc.

Cell F2 shows the score of 52% that was achieved by the student "Anne" in an examination. The Vlookup function in cell G2 looks up this score in column A of the spreadsheet and returns the associated grade from column C. Note that, in this example, if the exact score of 52% is not found in column A, we want, instead, to use the nearest value below this score.

 ABCDEFG 
1LowerUpperGrade NameScoreGrade 
20%44%F Anne52% =VLOOKUP( F2, A2:C7, 3, TRUE )  - returns the value "E"
345%54%E     
455%64%D     
565%74%C     
675%84%B     
785%100%A     

The above Vlookup function returns the grade for the score 52%, which is E.

In this example:


Further Vlookup Examples

For a practical example of the Vlookup function being used to create a variable chart, see the Excel Variable Chart page.

Also, there are several further Vlookup examples on the Microsoft Office website.


Using Vlookup in VBA

Although there is no VBA Vlookup function, you can call the Excel Worksheet Vlookup Function from VBA. See the VBA Vlookup page for more details.


Vlookup Function Errors

If you get a Vlookup error this is likely to be one of the following:

Common Errors
#N/A-

Occurs if the Vlookup function fails to find a match to the supplied lookup_value.

The cause of this will generally depend on the supplied [range_lookup] argument:
if [range_lookup] = TRUE
(or is omitted)
-

the #N/A error is produced if the smallest value in the left-hand column of the table_array is greater than the supplied lookup_value.

The #N/A error could also arise if the left column of the table_array is not in ascending order.

if [range_lookup] = FALSE-the #N/A error is likely to be because an exact match to the lookup_value is not found in the left-hand column of the table_array.

If you still can't understand why you are getting this Vlookup error, check out the Vlookup #N/A Error page.

#REF!-

Occurs if either:

  • The supplied col_index_num argument is greater than the number of columns in the supplied table_array.
or
  • The formula has attempted to reference cells that do not exist.
    This can be caused by relative referencing errors when the Vlookup is copied to other cells.

If you need further help with this Vlookup error, check out the Vlookup #REF! Error page.

#VALUE!-

Occurs if either:

  • The supplied col_index_num argument is < 1 or is not recognised as a numeric value.
or
  • The supplied [range_lookup] argument is not recognised as TRUE or FALSE.
For further Vlookup troubleshooting tips, there is an excellent Quick Reference Card available on the Microsoft Office website