The INDEX function is commonly used in combination with the MATCH function to provide powerful and dynamic lookup formulas.
This post will just focus on explaining the how the INDEX function works. It is best to understand the basics of INDEX before creating more advanced formulas using INDEX & MATCH.
Series: The Lookup Functions Explained
This is the third post in a series about the most commonly used lookup functions in Excel.
- In the first post I explained the VLOOKUP function at Starbucks.
- The second post explained how to make lookup formulas more dynamic with the VLOOKUP & MATCH functions.
- In this third post I will explain the INDEX function.
The INDEX Function is a Road Map
The INDEX function always reminds me of reading a road map.
As a kid, I had a fascination with maps. My parents always let me be the “navigator” on long road trips, and my job was to figure out where we were going and follow our course on the map.
The old road maps were laid out in a grid with columns and rows, just like an Excel spreadsheet.
You would first have to find the coordinates of your destination in the index of the map book, then locate the page and grid square (cell) that your destination was in.
The INDEX function in Excel is very similar to this. Its job is to return a cell value based on the grid coordinates that you feed it.
It is a very simple function.
I believe it has a reputation for being difficult and confusing because you have to combine it with a MATCH function to use it as a lookup formula.
So we are just going to start with the basics of how the INDEX function works.
Download the Example File
Please fill out the form below to download the example files immediately.
The INDEX Function Explained
The INDEX function returns the value of a cell based on the grid coordinates you provide it.
There are three arguments to the INDEX function.
=INDEX(array, row_num, [column_num])
Let’s look back at our Starbucks menu example to learn about the arguments in the INDEX function. This time we will use the INDEX function to answer the same question from the VLOOKUP example.
“What is the price of the Caffe Mocha, size Grande?”
1. array – This is the where argument.
This argument tells the INDEX where we want to look in the spreadsheet. You specify a range like A1:D10.
To me this is very similar to the page in the map book. We first need to tell INDEX where we are going to look, then zoom in on the exact coordinates.
The next two arguments are the coordinates.
2. row_num – This is the row number of the array that we want to return the result from.
In our example, we want to return a result from row 5. Since Caffe Mocha is in row 5 of the array, we simply put a 5 in the second argument of the formula.
3. column_num – This is the column number of the array that we want to return the result from.
We know that we want to return a price from the size Grande column, which is in column 3 of the array. So we can put a 3 in the third argument of the function.
The INDEX formula returns the result: $3.95. This is the value of cell C5 in the worksheet.
I hope this helps explain how simple the INDEX function is. You just tell it where you want to look (the array), and then give it the coordinates (the row & col numbers) of the cell value you want to return.
Row and Column Numbers are Relative to the Array Range
One important thing to note is that the row and column numbers we used in the INDEX function are relative to the array range ($A$1:$D$10).
In the example above we used row 5 and column 3 in the INDEX function. This is NOT necessarily the row and column number of the worksheet. The array range in our formula starts in cell A1, so the column and row number of the array will be the same as the column and row number of the worksheet.
If however, the array range started in cell B2, then the array range would be $B$2:$E$11. The price for the Caffe Mocha size Grande would still be in the 5th row and 3rd column of the array range. Therefore, the row and column arguments in the formula would remain 5 and 3.
You can see that the column and row numbers are specific to the array range, NOT the worksheet.
This should give you a basic understanding of how the INDEX function works.
It also explains that 20 years later, my fascination for maps and grids has not changed. 🙂
In the next post in this series I will discuss how the INDEX and MATCH functions can be combined to create powerful lookup formulas that can have advantages over the traditional VLOOKUP.
Here are links to the other two posts in this series about LOOKUP functions.
Please leave a comment below with any questions.
Take the VLOOKUP Challenge
I've put together 5-part video training series that will help you learn more about lookup formulas and test your skills.