Those of you who understand what dollars do in Formulae and functions you can even put them dollars for J1 and A1:G3 in the original Vlookup on the J2 Cell and then simply copy and paste the cell down to J3: J7. All you’ll have to change is the Column Index Number depending on the position of the headings in our table array.
Similar can be done for the Products information on the invoice sheet.
I hope this all makes sense so far. Now the question is if we can get the result we need from Vlookup then what is all the fuss about the other two functions called Index and Match?
Well as with all great things Vlookup has it’s drawback. And the drawback is quite a significant one. Notice that Customer ID is the Lookup value in our Vlookup function. And coincidently in our table array on the customers sheet Customer ID happens to be our first column. Well what that means is that had our first column in our Customer sheet been anything else Vlookup would not have worked. The problem we have is that Vlookup can only look at the left most (first) column in the table array and match that with the Lookup Value and then provide you the answer. In our case this seemed to work perfectly but then there are cases when it doesn’t work at all and Vlookup’s cousins Match and Index come to its rescue.
Let’s see the example where Vlookup will not work:
Let’s say that you knew the name and wanted to find the customer ID! That would be a problem! Because Vlookup will still be looking for first column i.e. Customer ID whereas we wanted to actually to look into the Second column to find us the data in the first column.
MATCH(lookup_value,lookup_array,match_type)
Lookup_value is the value you use to find the value you want in a table.
Lookup_array is a contiguous range of cells containing possible lookup values.
Match_type is the number -1, 0, or 1. Match_type specifies how Microsoft Excel matches lookup_value with values in lookup_array.
If match_type is 1, MATCH finds the largest value that is less than or equal to lookup_value. Lookup_array must be placed in ascending order.
If match_type is 0, MATCH finds the first value that is exactly equal to lookup_value. Lookup_array can be in any order.
If match_type is -1, MATCH finds the smallest value that is greater than or equal to lookup_value. Lookup_array must be placed in descending order.
If match_type is omitted, it is assumed to be 1.
So in our example we will type:
=MATCH(B6,B2:B3,0)
Notice that for the lookup array must be single column list. So if we had chosen A2:C3 you’ll get an error.
So the result of the Match function will be 2 because what Match tells you is the Row position of the entry in our Lookup value cell.
How helpful is this? Well not very much! So has Match Function disappointed us? Well Not really. At least it is telling us which Row number
Let’s See what Index Function can do for us.
=INDEX(data range, row number, column number)
Data range is the where you are looking into
Row Number is ,well, the row number
Column Number is well obviously the column number.
In our example the data range is easy to find that is the entire table. (A2:C3)
Column number is also easy to find as we know that we need the Customer ID to be extracted and that is in Column 1 in our data range , therefore, 1.
Although Row number in our example is not that difficult to find as we know that it is 2 but then the problem is that if we manually type 2 there the name we entered in cell B6 which is currently Mary Jones to john Smith who happens to be on row 1 unfortunately the result on cell B7 will not update as it will still be looking for Row 2 whereas the result should be coming from row 1.
So we need something in the Index Function that will automatically calculate the row number without us having to change it manually all the time. In addition to that if you have 20,000 rows of data would you manually want to search and type the row number yourself? I am hoping your answer is NO!
So what is the solution. That is where these Index and Match functions work in conjunction to get your desired result.
So your enter the Match function inside the Index function.
In our example the function would be something like this:
=INDEX(A2:C3,MATCH(B6,B2:B3,0),1)
So Match function tells the Index Function which row needs to be retrieved in order to get the correct result.
I hope this makes things clear for you!
Now for the BIGGEST question of All!! Where is that Blooming Magic Wand???? Well you don’t need one by understanding whatever is mentioned above you would be a proud owner of THREE Magic Wands: VLOOKUP, MATCH AND INDEX!!