VLOOKUP function

This article describes the formula syntax and usage of the VLOOKUPfunction in Microsoft Excel.

Description

You can use the VLOOKUP function to search the first column of a range of cells, and then return a value from any cell on the same row of the range. For example, suppose that you have a list of employees contained in the range A2:C10. The employees' ID numbers are stored in the first column of the range, as shown in the following illustration.

A range of cells on a worksheet

If you know the employee's ID number, you can use the VLOOKUP function to return either the department or the name of that employee. To obtain the name of employee number 38, you can use the formula =VLOOKUP(38, A2:C10, 3, FALSE). This formula searches for the value 38 in the first column of the range A2:C10, and then returns the value that is contained in the third column of the range and on the same row as the lookup value ("Axel Delgado").

The V in VLOOKUP stands for vertical. Use VLOOKUP instead of HLOOKUP when your comparison values are located in a column to the left of the data that you want to find.

Syntax

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

The VLOOKUP function syntax has the following arguments:

  • lookup_value    Required. The value to search in the first column of the table or range. The lookup_value argument can be a value or a reference. If the value you supply for the lookup_value argument is smaller than the smallest value in the first column of the table_array argument, VLOOKUP returns the #N/A error value.

  • table_array    Required. The range of cells that contains the data. You can use a reference to a range (for example, A2:D8), or a range name. The values in the first column of table_array are the values searched by lookup_value. These values can be text, numbers, or logical values. Uppercase and lowercase text are equivalent.

  • col_index_num    Required. The column number in the table_array argument from which the matching value must be returned. A col_index_num argument of 1 returns the value in the first column in table_array; a col_index_num of 2 returns the value in the second column in table_array, and so on.

    If the col_index_num argument is:

    • Less than 1, VLOOKUP returns the #VALUE! error value.

    • Greater than the number of columns in table_array, VLOOKUP returns the #REF! error value.

  • range_lookup    Optional. A logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match:

    • If range_lookup is either TRUE or is omitted, an exact or approximate match is returned. If an exact match is not found, the next largest value that is less than lookup_value is returned.

      Important   If range_lookup is either TRUE or is omitted, the values in the first column of table_array must be placed in ascending sort order; otherwise, VLOOKUP might not return the correct value.

      For more information, see Sort data in a range or table.

      If range_lookup is FALSE, the values in the first column of table_array do not need to be sorted.

    • If the range_lookup argument is FALSE, VLOOKUP will find only an exact match. If there are two or more values in the first column of table_array that match the lookup_value, the first value found is used. If an exact match is not found, the error value #N/A is returned.

Remarks

  • When searching text values in the first column of table_array, ensure that the data in the first column of table_array does not contain leading spaces, trailing spaces, inconsistent use of straight ( ' or " ) and curly ( ‘ or “) quotation marks, or nonprinting characters. In these cases, VLOOKUP might return an incorrect or unexpected value.

    For more information, see CLEAN function and TRIM function.

  • When searching number or date values, ensure that the data in the first column of table_array is not stored as text values. In this case, VLOOKUP might return an incorrect or unexpected value.

  • If range_lookup is FALSE and lookup_value is text, you can use the wildcard characters — the question mark (?) and asterisk (*) — in lookup_value. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) preceding the character.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

ID

Last name

First name

Title

Birth date

101

Davis

Sara

Sales Rep.

12/8/1968

102

Fontana

Olivier

V.P. of Sales

2/19/1952

103

Leal

Karina

Sales Rep.

8/30/1963

104

Patten

Michael

Sales Rep.

9/19/1958

105

Burke

Brian

Sales Mgr.

3/4/1955

106

Sousa

Luis

Sales Rep.

7/2/1963

Formula

Description

=VLOOKUP("Fontana",B2:E7,2,FALSE)

Looks for the value Fontana in the first column (column B) of table_array B2:E7 and returns the value Olivier found in the second column (Column C) of the table_array. The range_lookup FALSE returns an exact match.

=VLOOKUP(102,A2:C7,2,FALSE)

Searches for an exact match of the last name for lookup_value102 in column A. Fontana is returned. If Lookup_value is 105, Burke is returned.

=IF(VLOOKUP(103,A1:E7,2,FALSE)="Sousa","Located","Not found")

Checks to see if the last name of Employee with ID 103 is Sousa. Because 103 is actually Leal, the result is Not found. If you change "Sousa" to "Leal" in the formula, the result is Located.

=INT(YEARFRAC(DATE(2014,6,30), VLOOKUP(105,A2:E7,5, FALSE), 1))

For the fiscal year 2014, finds the age of the employee with ID 105. Uses the YEARFRAC function to subtract the birth date from the fiscal year end date and displays the result 59 as an integer using the INT function.

=IF(ISNA(VLOOKUP(105,A2:E7,2,FALSE)) = TRUE, "Employee not found", VLOOKUP(105,A2:E7,2,FALSE))

If there is an employee with ID 105, displays the employee's last name, which is Burke. Otherwise, displays the message Employee not found. The ISNA function (one of the IS functions) returns a TRUE value when the VLOOKUP function returns the #N/A error value.

=VLOOKUP(104,A2:E7,3,FALSE) & " " & VLOOKUP(104,A2:E7,2,FALSE) & " is a " & VLOOKUP(104,A2:E7,4,FALSE)

For the employee with ID 104, concatenates (combines) the values of three cells into the complete sentence Michael Patten is a Sales Rep.

See Also

YEARFRAC function

INT function

IS functions

CONCATENATE function

Applies To: Excel 2007, Excel 2010, Excel Starter, Excel Online, SharePoint Online



Was this information helpful?

Yes No

How can we improve it?

255 characters remaining

To protect your privacy, please do not include contact information in your feedback. Review our privacy policy.

Thank you for your feedback!

Support resources

Change language