Sunday 21 June 2015

The Excel VLOOKUP function

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 format 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 for, in the left-hand column of the supplied data array
table_array- The data array or table, that you want to search the left hand column of, for the supplied lookup_value
col_index_num- The column number, within the supplied array, that you want the corresponding value to be returned from
[range_lookup]- An optional logical argument, which 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 range_lookup is set to TRUE, 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



Vlookup Examples

Vlookup Example 1

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 )
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:
-the lookup_value is the text string "Cornflakes", which is located in cell D2
-the table_array is columns A-B of the spreadsheet
-the col_index_num is set to 2, to denote that the value returned should be taken from column 2 of the table_array
-the range_lookup argument is set to FALSE, to indicate that we only want a result to be returned if an exact match to the lookup_value is found

No comments:

Post a Comment