INDEX function

The INDEX function returns a value or the reference to a value from within a table or range.

There are two ways to use the INDEX function:

  • If you want to return the value of a specified cell or array of cells, see Array form.
  • If you want to return a reference to specified cells, see Reference form.

Description

Returns the value of an element in a table or an array, selected by the row and column number indexes.

Use the array form if the first argument to INDEX is an array constant.

Syntax

INDEX(array, row_num, [column_num])

The array form of the INDEX function has the following arguments:

  • array    Required. A range of cells or an array constant.
    • If array contains only one row or column, the corresponding row_num or column_num argument is optional.
    • If array has more than one row and more than one column, and only row_num or column_num is used, INDEX returns an array of the entire row or column in array.
  • row_num    Required, unless column_num is present. Selects the row in array from which to return a value. If row_num is omitted, column_num is required.
  • column_num    Optional. Selects the column in array from which to return a value. If column_num is omitted, row_num is required.

Remarks

  • If both the row_num and column_num arguments are used, INDEX returns the value in the cell at the intersection of row_num and column_num.
  • row_num and column_num must point to a cell within array; otherwise, INDEX returns a #REF! error.
  • If you set row_num or column_num to 0 (zero), INDEX returns the array of values for the entire column or row, respectively. To use values returned as an array, enter the INDEX function as an array formula.Note: If you have a current version of Microsoft 365, then you can input the formula in the top-left-cell of the output range, then press ENTER to confirm the formula as a dynamic array formula. Otherwise, the formula must be entered as a legacy array formula by first selecting the output range, input the formula in the top-left-cell of the output range, then press CTRL+SHIFT+ENTER to confirm it. Excel inserts curly brackets at the beginning and end of the formula for you. For more information on array formulas, see Guidelines and examples of array formulas.

Examples

Example 1

These examples use the INDEX function to find the value in the intersecting cell where a row and a column meet.

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter.

DataData
ApplesLemons
BananasPears
FormulaDescriptionResult
=INDEX(A2:B3,2,2)Value at the intersection of the second row and second column in the range A2:B3.Pears
=INDEX(A2:B3,2,1)Value at the intersection of the second row and first column in the range A2:B3.Bananas

Example 2

This example uses the INDEX function in an array formula to find the values in two cells specified in a 2×2 array.  

Note: If you have a current version of Microsoft 365, then you can input the formula in the top-left-cell of the output range, then press ENTER to confirm the formula as a dynamic array formula. Otherwise, the formula must be entered as a legacy array formula by first selecting two blank cells, input the formula in the top-left-cell of the output range, then press CTRL+SHIFT+ENTER to confirm it. Excel inserts curly brackets at the beginning and end of the formula for you. For more information on array formulas, see Guidelines and examples of array formulas.

FormulaDescriptionResult
=INDEX({1,2;3,4},0,2)Value found in the first row, second column in the array. The array contains 1 and 2 in the first row and 3 and 4 in the second row.2
Value found in the second row, second column in the array (same array as above).4

Leave a Comment

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