Search This Blog

Thursday 10 January 2013

How to use Vlookup

 Useful for matching rows between two sets of tables.


Vlookup is good for:
  1. Appending columns from this table to that table.
  2. Finding missing records.
  3. Finding similar records.


Inputs for Vlookup:
  1. Lookup_value: The value to search in Table_array
  2. Table_array: The set of table to search upon, first column in your selection will be matched with Lookup_value in the search.
  3. Col_index_num: Column number in your Table_array to return when a match is found.
  4. Range_lookup: I always set to false for an exact match. Try true to return the next largest value that is less than the Lookup_value (You can imagine the funny results involving text lookups when Range lookup is set to true, therefore I always set it to false)
See the example below on getting names from the left table to the right table based on the GuestID

Claire was formulated on I3 with the formula =VLOOKUP(G3, $A$3:$C$6, 2, 0), in human language means search for G3 in Guest table (A3:C6) and return column 2 (Name) of Guest Table if found, use exact matching. To append the name and age to the rest of the rows in Guest Check in Log, just copy and paste from cell I3 and J3, Excel automatically increments the Lookup_Value



IMPORTANT: A common mistake is forgetting to fix the selection of table array when applying vlookup for the whole column by copying and pasting the formula for every row. To prevent that, put $ in front of the column and row labels eg. $A$1:$B$3, just highlight the range and press F4 to do that.


It's best to have an unique column to identify your rows between two sets of data for a good look up. What if an unique identity for a row is not available? What I will do is use the "&" to join some columns together, columns that you feel when combined, forms a unique identity 

See the column Created Identity as an example


That's all! Simple and useful function, good luck finding stuff! 


No comments:

Post a Comment