Friday, March 9, 2012

Excel Vlookup Lesson

Everyone uses excel to some degree. I'm going to try and teach you how to use vlookup a useful tool for pulling data from one page to another.

We will look at the directions from Microsoft vlookup  and expand on them
VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)
Lookup_value    The value to search in the first column of the table array. Lookup_value can be a value or a reference. If lookup_value is smaller than the smallest value in the first column of table_array, VLOOKUP returns the #N/A error value.
Table_array    Two or more columns of data. Use a reference to a range 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    The column number in table_array from which the matching value must be returned. A col_index_num 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 col_index_num 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    A logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match:
  • If TRUE or 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.
The values in the first column of table_array must be placed in ascending sort order; otherwise, VLOOKUP may not give the correct value. You can put the values in ascending order by choosing the Sort command from the Data menu and selecting Ascending. For more information, see Default sort orders.
  • If FALSE, VLOOKUP will only find an exact match. In this case, the values in the first column of table_array do not need to be sorted. 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.

So  VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)

My quick example with some notes:

=VLOOKUP(B1,Sheet2!A1:H34,3,FALSE)

So we are looking at Sheet2 columns A1:H34 for an exact match to B1.

if we find a match we return column #3 in the table_array which in this case is column C.

if we we don't find an exact match it will return #N/A. if we want it to return another value we can place an If statement before the VLOOKUP

=IF(ISNA(VLOOKUP(B1,Sheet2!A1:H34,3,FALSE)),"",(VLOOKUP(B1,Sheet2!A1:H34,3,FALSE)))
Now what we did here was perform a check to see if the result of the VLOOKUP is NA =IF(ISNA(VLOOKUP(B1,Sheet2!A1:H34,3,FALSE))
 If this statement is true we return the value "" or a blank cell.

if it is false we know there is a value that matches our VLOOKUP and can proceed as normal.

No comments:

Post a Comment