How to use the INDEX function in Excel?

Last Updated on 07/05/2024
Reading time: 3 minutes

The INDEX function in Excel returns a value according to its position in a table.

VLOOKUP vs INDEX

The difference between VLOOKUP and INDEX functions is not apparent to many people. The difference is quite simple.

  • VLOOKUP searches by value (employee name, product name, product code, ...)
  • INDEX searches by position (for instance, returns the value in column 2 and row 5)

There is no difference between the two functions in terms of search speed.

Presentation of the function INDEX

The function INDEX in Excel works with three arguments

  1. Identify the range of cells containing the data you want to reference

    This range can be a single cell, a row, a column, or a block of cells

  2. Determine the row position of the value you want to return.

    The row position is the row number containing the value, starting with 1 for the top row.

  3. Determine the column position of the value you want to return.

    The column position is the number of the column containing the value

The order of parameters is very important. Often, users reverse the settings of the row and the column, and inevitably, the function does not return the correct result.

INDEX returns the distance between cities

Example: INDEX to return the month name

  • Let's say you have the list of the months' names on a worksheet.
  • What is month #6?
  • Well, it's easy to find the answer with the function INDEX.

=INDEX(A2:A13,6)

INDEX returns the month name in function of its position in the list

But of course, we can replace the value 6 with the reference of a cell, like this

=INDEX(A2:A13,C1)

The position in the reference table is returned by a cell reference

Now, If the data source is in a row, the function's writing is slightly different.

  • The second argument is = 1 (search on the first row)
  • The third argument is the position

=INDEX(C3:I3,1,D8)

INDEX with the reference table in horizontal orientation

Function to return the position

So, INDEX expects a rank to return a value in your reference table. But if you have a huge list of values on your table, like customers' names, how do you find the position of clients Smith or Garcia?

This is where the function MATCH will help you to convert a value to a position. For instance, we select a month, and the MATCH function returns the rank.

=MATCH(E1,C1:C7)

MATCH returns the position of the days

Function INDEX with 2 dimensions

The INDEX function is powerful with a 2-dimensional array. Most Excel users use it to return the value of a cell inside a grid of data. For example, we want to return the distance between 2 cities (the explanation to build such a cross table in this article)

Distance between US cities

So here, we must convert the name of the cities as a position with the function MATCH

=MATCH(B10,A2:A8,0)

MATCH returns the position of a city name in the list in column A

Then, we will use this information in the INDEX function to return the distance between the cities

=INDEX(B2:H8,C10,C11)

Your selection mustn't include the headers.

INDEX returns the distance between cities

Leave a Reply

Your email address will not be published. Required fields are marked *

How to use the INDEX function in Excel?

Reading time: 3 minutes
Last Updated on 07/05/2024

The INDEX function in Excel returns a value according to its position in a table.

VLOOKUP vs INDEX

The difference between VLOOKUP and INDEX functions is not apparent to many people. The difference is quite simple.

  • VLOOKUP searches by value (employee name, product name, product code, ...)
  • INDEX searches by position (for instance, returns the value in column 2 and row 5)

There is no difference between the two functions in terms of search speed.

Presentation of the function INDEX

The function INDEX in Excel works with three arguments

  1. Identify the range of cells containing the data you want to reference

    This range can be a single cell, a row, a column, or a block of cells

  2. Determine the row position of the value you want to return.

    The row position is the row number containing the value, starting with 1 for the top row.

  3. Determine the column position of the value you want to return.

    The column position is the number of the column containing the value

The order of parameters is very important. Often, users reverse the settings of the row and the column, and inevitably, the function does not return the correct result.

INDEX returns the distance between cities

Example: INDEX to return the month name

  • Let's say you have the list of the months' names on a worksheet.
  • What is month #6?
  • Well, it's easy to find the answer with the function INDEX.

=INDEX(A2:A13,6)

INDEX returns the month name in function of its position in the list

But of course, we can replace the value 6 with the reference of a cell, like this

=INDEX(A2:A13,C1)

The position in the reference table is returned by a cell reference

Now, If the data source is in a row, the function's writing is slightly different.

  • The second argument is = 1 (search on the first row)
  • The third argument is the position

=INDEX(C3:I3,1,D8)

INDEX with the reference table in horizontal orientation

Function to return the position

So, INDEX expects a rank to return a value in your reference table. But if you have a huge list of values on your table, like customers' names, how do you find the position of clients Smith or Garcia?

This is where the function MATCH will help you to convert a value to a position. For instance, we select a month, and the MATCH function returns the rank.

=MATCH(E1,C1:C7)

MATCH returns the position of the days

Function INDEX with 2 dimensions

The INDEX function is powerful with a 2-dimensional array. Most Excel users use it to return the value of a cell inside a grid of data. For example, we want to return the distance between 2 cities (the explanation to build such a cross table in this article)

Distance between US cities

So here, we must convert the name of the cities as a position with the function MATCH

=MATCH(B10,A2:A8,0)

MATCH returns the position of a city name in the list in column A

Then, we will use this information in the INDEX function to return the distance between the cities

=INDEX(B2:H8,C10,C11)

Your selection mustn't include the headers.

INDEX returns the distance between cities

Leave a Reply

Your email address will not be published. Required fields are marked *