ShareYourGroupShareYourGroupGoogle Sheets

Lookup

VLOOKUP function in Google Sheets

VLOOKUP finds a value in the first column of a range and returns a value from the same row in another column.

VLOOKUP fetches a detail from a table: the price for a code, the name for a roll number. It behaves in Google Sheets as it does in Excel, with a few extras that come from the way Sheets handles arrays.

Syntax

=VLOOKUP(search_key, range, index, [is_sorted])
ArgumentWhat it is
search_keyThe value to look for.
rangeThe table to search. The key is looked for in its first column.
indexWhich column of the range to return, counting from 1.
is_sortedFALSE for an exact match. TRUE, or left out, assumes the first column is sorted and returns the nearest match at or below the key.

Examples

Sample sheet: A small price list with item codes. The table is sorted by code.
ABCDE
1CodeItemCategoryPriceStock
2A101Basmati Rice 5 kgGrocery65040
3A102Toor Dal 1 kgGrocery16075
4B201NotebookStationery60300
5B202Ball PenStationery100
6C301LED BulbElectronics110200
7C302Power BankElectronics129918
8D401Steel BottleHome45055
Sample sheet: A marks table and a grade table. The grade table lists the lowest mark of each grade, in rising order.
ABCDE
1NameMarksFromGrade
2Asha910E
3Ravi4533D
4Meena7950C
5Kabir2865B
6Tara6580A

How it works

VLOOKUP searches down the first column of the range for the key, then moves across to the column number you gave and returns that cell.

The fourth argument decides the kind of match. Type FALSE for codes, names and anything that must match exactly. If you leave it out, Sheets assumes the first column is sorted and returns the closest value at or below the key, which on unsorted data gives wrong answers without an error.

The sorted mode is right for bands: tax slabs, grade boundaries, delivery charges by weight. List the lowest value of each band in the first column, in rising order.

One formula for a whole column

In Sheets, VLOOKUP expands inside ARRAYFORMULA. Put this in the first row:

=ARRAYFORMULA(IF(A2:A="", "", VLOOKUP(A2:A, Prices!A:D, 4, FALSE)))

It fills the whole column, and new rows are looked up as they are added. No copying down, and no dollar signs to forget.

Several columns at once

Give the index as a list in curly brackets, {2,4}, and VLOOKUP returns those columns side by side, as the sixth example shows. Excel's VLOOKUP needs a separate formula for each column.

Looking to the left

VLOOKUP's key must be in the first column of the range. Sheets offers a neat way round: build a range in the order you need with curly brackets.

=VLOOKUP("Notebook", {B2:B8, A2:A8}, 2, FALSE)

The braces make a two-column range with the names first and the codes second. Many people prefer XLOOKUP or INDEX with MATCH, which look in any direction.

A table in another file

The range can come from another spreadsheet through IMPORTRANGE: =VLOOKUP(A2, IMPORTRANGE(url, "Prices!A:D"), 4, FALSE). For many lookups, import the table once to a tab of its own and look it up there. It is much faster.

Why you get #N/A

Capital and small letters are treated as the same.

Common mistakes

In Excel

The same function with the same four arguments. Excel calls them lookup_value, table_array, col_index_num and range_lookup. The ARRAYFORMULA and curly-bracket tricks are particular to Sheets. Modern Excel spills a list of keys without a wrapper.

Related functions

The results on this page were worked out by us from the sample sheet; they were not produced by a script running Google Sheets. If Sheets shows you something different, please tell us.

This is an independent help site. It is not connected with or approved by Google. Google Sheets is a trademark of Google LLC, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.