Intermediate Excel VLOOKUP INDEX MATCH

advertisement
I.
VLOOKUP
VLOOKUP is the most basic lookup function in Excel. It is designed to return a value a set
number of columns to the right of the first time that value shows up in a target array.
VLOOKUP is limited in that it can only find values to the right of the column where the target
is being looked up. There are more complex formulas that can look up in all directions as
well as methods for looking up items in multiple columns/rows with multiple criteria.
A. VLOOKUP is limited to finding values to the right of the key. In our data set in the VLOOKUP
Data tab, the NPI is our unique key, but it is to the right of the information we want to look
up. We will have to insert a column before column A and move the NPI data to the new
blank column. Sometimes, a combination of 2 fields is required to create a unique
identifier. In these cases, combining 2 or more cells with the “&” will suffice in column A.
B. =VLOOKUP($A7,'VLOOKUP Data'!$A$1:$J$14,2,FALSE)
Write the above formula in Cell B7 of the VLOOKUP tab. VLOOKUP is a vertical lookup. You
are looking for the value in cell A7 in the current worksheet. The value will be in the range
of Cells A1 through J14 in the worksheet, “VLOOKUP Data”. The VLOOKUP will only look up
the value in the leftmost column in the range which, in this example, is column A. The
VLOOKUP will settle on the FIRST value in column A that is an exact match for what was in
cell A7. The values we are seeking must be no farther right than the end of the array, which
in this example is column J. VLOOKUP will not return any values to the right of column J or
in rows less than row 14. Return the value in the second column of this array. In this case,
that would be column B. False requires an exact match to the value in A7. Using True or
excluding False will lead to a lot of false positives. I have yet to find a use for the “True”
statement in this formula. Copy the formula down for all NPIs. Next, copy the formula into
columns C through E and modify the formula to find the first name, department, and birth
date.
II.
HLOOKUP
A. HLOOKUP is a VLOOKUP that is rotated 90 degrees. Instead of finding a value in a column,
HLOOKUP uses a row. The structure of the HLOOKUP mirrors that of the VLOOKUP.
B. =HLOOKUP($A7,'HLOOKUP Data'!$A$1:$N$11,2,FALSE)
Write the above formula in Cell B7 of the HLOOKUP tab. HLOOKUP is a horizontal lookup.
You are looking for the value in cell A7 in the current worksheet. The value will be in the
range of Cells A1 through N11 in the worksheet, “HLOOKUP Data”. The HLOOKUP will only
look up the value in the topmost column in the range which, in this example, is Row 1. The
HLOOKUP will settle on the FIRST value in Row 1 that is an exact match for what was in cell
A7. The values we are seeking must be no farther down than the bottom of the array, which
in this example is Row 11. HLOOKUP will not return any values to the right of column N or in
rows less than row 11. Return the value in the second row of this array. In this case, that
would be Row 2. False requires an exact match to the value in A7. Using True or excluding
False will lead to a lot of false positives. I have yet to find a use for the “True” statement in
this formula. Copy the formula down for all NPIs. Next, copy the formula into columns C
through E and modify the formula to find the first name, department, and birth date.
III.
INDEX MATCH broken down separately (INDEX And MATCH Tutorial)
A. INDEX MATCH works like a combination of a VLOOKUP and an HLOOKUP. It identifies the
first instance of a value in a row and another value in a column then returns the value of the
point where the two items intersect. When INDEX and MATCH are used in conjunction,
there is no need to move the key columns or rows to the top or left of the array. The
function works on any row or column within the array.
B. INDEX – By itself, this is not a very useful formula. Type the following formula anywhere in
the INDEX And MATCH Tutorial Tab:
=INDEX($I$6:$R$19,3,2)
Return the point of intersection for the following coordinates. In the array I6:R19: Return
the value of the cell that is plotted in the 3rd row from the top and the second column in the
array. The 3rd row in the array is row 8. The 2nd column is J. The result of this formula
should be “Pavel”. By itself, INDEX seems like a fairly useless function. When combined
with 2 MATCH statements, it becomes one of the most useful formulas in all of Excel. It is
the personal favorite of your instructor.
C. MATCH – The MATCH statement returns the order number of the cell in an array in which
the exact match first appears. This statement works in both rows and columns. Type the
following formula in Cell C13 of the INDEX And MATCH Tutorial worksheet:
=MATCH($B13,$R$6:$R$19,0)
Find the relative position of the value of Cell B13 in the Array of R6 through R19. The match
must be exact. The formula should return the value of 9. This is the 9th item in this array.
The array must be restricted to a single row or single column. Now, try a similar formula in
cell C14 to do the same thing only using a row as our array:
=MATCH($B14,$I$6:$R$6,0)
Find the relative position of the value of Cell B14 in the Array of I6 through R6. The match
must be exact. The formula should return the value of 7. This is the 7th item in this array.
D. Putting it all together. The INDEX function uses two coordinates on the y and x axis to
return a value where the intercepts meet. MATCH identifies a variable on either a y or x
axis. Substitute the first MATCH statement for the 3 in the INDEX Statement above.
Substitute the 2nd MATCH Statement for the 2 in the INDEX Statement above.
=INDEX($I$6:$R$19,MATCH($B13,$R$6:$R$19,0),MATC
H($B14,$I$6:$R$6,0))
The result should be “MI” We found NPI number, 367315673 in column R and “State” which
was the column header in row 6. The point where both intersect is Cell O14. The formula
returns the value of this cell, “MI”.
It is important to make sure that your MATCH statements line up with the start points in the
first part of the INDEX array. Failure to start in the same row or column can lead to skewing
the value returned. The start point for rows in this example should be row 6 and the start
point for the columns is I.
IV.
INDEX MATCH – Putting it all together and mass producing (INDEX MATCH Tab)
A. Enter an INDEX MATCH Statement in Cell B7 that will reference the INDEX Data Tab
=INDEX('INDEX Data'!$A$1:$J$14,MATCH($A7,'INDEX
Data'!$J$1:$J$14,0),MATCH(B$6,'INDEX
Data'!$A$1:$J$1,0))
Find the intersection in the array A1:J14 on the INDEX Data Tab. The y coordinate is the
relative position of the value of A7 in the array J1:J14 in the INDEX Data Tab. The x
coordinate is the relative position of the value of B6 in the array A1:J1. Return the value of
the cell at this intersection.
B. Mass Production – Notice that the $A7 uses an absolute column reference and a variable
row reference. Copying this down will allow the row number to change. B$6 in the above
statement uses an absolute row reference and a variable column reference. Copying this to
the right will lock the row yet allow the column to shift. Copy your formula to the right and
down. All of the fields will be populated. Substitute or add on different column headers on
row 6 and watch your values change. This is a huge time saver when compared to VLOOKUP
for multiple fields and a lot easier when your data is 30 columns wide.
Download