Two Dimensional VLOOKUP

September 6th, 2008 | Categories: LOOKUP | Tags: , , , , ,

The VLOOKUP and HLOOKUP functions are well known for looking up data in one dimension:

And then:

However what happens if we have a TWO dimensional array

And we want to find the value for Boats in Mar-08.  So we could add two drop downs to specify the mode of transport and the month that we need:

Excel provides a function called INDEX that allows us to return values from a 2d array:
INDEX(Array_Range, Row Number, Col Number)

Where
•    Array_Range  is the range in Excel of the two dimensional array – in this case $B$4:$H$7
•    Row Number  is the position in the list where we find the text “Boat”  – in this case is 1
•    Col Number is the position in the list where we find the month “Mar-08”

Of course the only thing left to do is to determine the Row and Column Number. This is done by using the MATCH function – which returns the position of a string within a range of values:
MATCH(“String”, Range,0) – will return the position of  “String” in the array “Range” and the 0 states that we want an exact match. So we are looking for the position of Boats in the range {Boats, Cars, Planes , Lorries} – which is 1. This will give the row number:

MATCH(B11,$B$4:$B$7,0)
And similarly for the column number
MATCH(C11,$C$2:$H2,0)
And then we combine all these into one function:
=INDEX($C$4:$H$7,MATCH(B11,$B$4:$B$7,0),MATCH(C11,$C2:$H$2,0))
To give the value of 79 for boats in March 2008:

  1. Client
    September 13th, 2008 at 02:13
    Reply | Quote | #1

    Very intersting…

  2. Rich Peterson
    February 14th, 2009 at 16:29
    Reply | Quote | #2

    The exact function that I was Looking for Thank You!

  3. Kevin
    February 20th, 2010 at 13:18
    Reply | Quote | #3

    This was a great help and you did a good job at explaining the index and match function. I’m currently learning from the book, “Mastering Excel,” by James Gips and your explanation is much easier to follow.