When the VLOOKUP function is called, Excel searches for a lookup value in the leftmost column of a section of your spreadsheet called the table array. The function returns another value in the same row, defined by the column index number.
HLOOKUP is similar to VLOOKUP, but it searches a row instead of a column, and the result is offset by a row index number. The V in VLOOKUP stands for vertical search (in a single column), while the H in HLOOKUP stands for horizontal search (within a single row).
Let's use the workbook below as an example which has two sheets. The first is called Data Sheet. On this sheet, each row contains information about an inventory item. The first column is a part number, and the third column is a price in dollars.
The second sheet is called Lookup Sheet, and it contains a formula which uses VLOOKUP to look up data on the Data Sheet. In the screenshot below, notice that cell B2 is selected, and its formula is listed in the formula bar at the top of the sheet.
The value of cell B2 is the formula =VLOOKUP(A2,'Data Sheet'!$A$2:$C$4,3,FALSE).
The above formula will populate the B2 cell with the price of the part identified in cell A2. If the price changes on the Data Sheet, the value of cell B2 on the Lookup Sheet will be updated automatically to match. Similarly, if the part number in cell A2 on the Lookup Sheet changes, cell B2 will automatically update with the price of that part.
Let's look at each element of the example formula in more detail.
|=||The equals sign (=) indicates that this cell contains a formula, and the result should become the value of the cell.|
|VLOOKUP||The name of the function.|
|(||An opening parenthesis indicates that the preceding name VLOOKUP was the name of a function, and indicates the beginning of a comma-separated list arguments to the function.|
|A2||An opening parenthesis indicates that the preceding name VLOOKUP was the name of a function, and indicates the beginning of a comma-separated list of arguments to the function.|
The second argument, the Table Array. It defines an area on a sheet to be used as the lookup table. The leftmost column of this area is the column that contains the Lookup Value.
The table array argument takes the general form:
The first part of this expression identifies a sheet, and the second part identifies a rectangular area on that sheet. Specifically:
The leftmost column of the table array must contain your lookup value. Always define your table array so that the leftmost column contains the value you're looking up.
This argument is required.
The third VLOOKUP argument, the Column Index Number. It represents the number of columns, offset from the leftmost column of the table array, where the result of the lookup will be found. For instance, if the leftmost column of the lookup array is C, a Column Index Number of 4 would indicate that the result should come from column E.
In our example, the leftmost column of the Table Array is A and we want a result from column C. A is the first column, B is the second column, and C is the third column, so our column index number is 3.
This argument is required.
The fourth argument is the Range Lookup value. It can be either TRUE or FALSE, and it specifies whether Excel should perform the lookup using "exact lookup" or "range lookup".
If you're not sure which type of match to use, choose FALSE for an exact match.
If you choose TRUE for a range lookup, make sure the data in the leftmost column of your table array is sorted in ascending order (least-to-greatest). Otherwise, the results will not be correct.
This argument is optional. If you omit this argument, an exact lookup will be performed.
|)||A closing parenthesis, which indicates the end of the argument list and the end of the function.|
- The lookup value must be in the left-most column of the table array. If not, the lookup function will fail.
- Make sure that every value in the left-most column of the table array is unique. If you have duplicate values in the column where the lookup takes place, the results of VLOOKUP are not guaranteed to be correct.