Menu

INDEX Function in Excel: Get a Value by Row and Column

=INDEX(A2:C6,3,2) returns the value in the third row and second column of A2:C6. Use it for the nth item of a list, a whole row or column, and the value at a position MATCH found.

Every sheet on this page is live: change a number or a formula and it recalculates.

=INDEX(A2:C6,3,2) returns the value in the third row and second column of the range A2:C6. Positions count from the range's top left cell, so row 3 of A2:C6 is sheet row 4. Change the 3 or the 2 and watch the result move.

Row 3, column 2 of the table
G2
ABCDEFG
1ProductCategoryPriceRowColumnResult
2AppleFruit$1.2032Vegetable
3PearFruit$1.50
4CarrotVegetable$0.80
5BreadBakery$2.40
6MilkDairy$1.10
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

E2 holds the row number and F2 the column number. Row 3 is Carrot and column 2 is Category, so G2 shows Vegetable. Set F2 to 1 for the product name, or E2 to 6 to see #REF!: A2:C6 has only five rows.

INDEX syntax

=INDEX(array, row_num, [column_num])
  • array: the range (or array) to read from.
  • row_num: which row of it, starting at 1. Use 0 for all rows.
  • column_num: which column, starting at 1. Optional when the range is a single column or a single row; use 0 for all columns.

On a single column, one number is enough: =INDEX(A2:A6,4) is the fourth item, Bread. A second form, =INDEX((A2:C3,A5:C6),1,1,2), picks from one of several ranges; it is rarely needed.

Get the nth item, or the last one

INDEX with a single column answers "what is item number n". Combined with COUNTA, which counts the filled cells, it returns the last item of a list that grows.

Nth and last item
D3
ABCD
1ProductItem number2
2AppleNth itemPear
3PearLast itemMilk
4Carrot
5Bread
6Milk
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

D1 says 2, so D2 returns Pear. COUNTA counts 5 products, so D3 returns the fifth, Milk. Delete Milk and D3 returns Bread. In a real file, point both at a longer range such as A2:A1000 so new rows are included; COUNTA only works this way when the column has no empty cells in the middle.

Return a whole row or column with 0

A 0 as the row number means "every row", so INDEX(B2:D5,0,2) is the whole second column. Inside SUM, AVERAGE or MAX, that totals a column chosen by number.

Total of one month
G2
ABCDEFG
1RegionJanFebMarMonth numberTotal
2North4,2003,9004,800215,200
3South3,1003,6003,300
4East5,2004,7005,600
5West2,8003,0003,400
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Month 2 is Feb, and G2 adds C2:C5: 15,200. Change F2 to 3 for March. A whole row works the same way: =SUM(INDEX(B2:D5,3,0)) totals East. In Excel 2021 and Microsoft 365, =INDEX(B2:D5,0,2) on its own spills the four values down the sheet. To choose the column by its header instead of a number, replace F2 with a MATCH, which is the INDEX and MATCH pattern.

INDEX on an array or a spilled result

INDEX also reads arrays that a formula returns, not only ranges on the sheet. That picks one item out of a sorted, filtered or unique list without writing the list out first.

Most and least expensive product
E2
ABCDEF
1ProductCategoryPriceMost expensiveBread
2AppleFruit$1.20SecondPear
3PearFruit$1.50CheapestCarrot
4CarrotVegetable$0.80
5BreadBakery$2.40
6MilkDairy$1.10
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

SORTBY returns the five products ordered by price, and INDEX takes item 1 (Bread), item 2 (Pear) or, from the ascending sort, item 1 (Carrot). Change Milk's price to 3 and it becomes the most expensive. If a spilled list already sits on the sheet, say in H2, Excel 2021 and Microsoft 365 let you write =INDEX(H2#,2) for its second item.

Practice: total a chosen month

Sales by month
G2
ABCDEFG
1RegionJanFebMarMonth numberTotal
2North4,2003,9004,8001
3South3,1003,6003,300
4East5,2004,7005,600
5West2,8003,0003,400
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Your turn: In G2, return the total of the month whose number is in F2 (1 = Jan, 2 = Feb, 3 = Mar), using INDEX.

Frequently Asked Questions

What does the INDEX function do in Excel?

It returns the value at a given position in a range: =INDEX(A2:C6,3,2) returns the value in the third row and second column of A2:C6. Positions count from the top left cell of the range, not from row 1 of the sheet.

How do I get the last value in a column with INDEX?

Use the count of filled cells as the row number: =INDEX(B2:B100,COUNTA(B2:B100)) returns the last value of a column with no gaps. With gaps, =LOOKUP(2,1/(B2:B100<>""),B2:B100) returns the last non-empty value.

Why does INDEX return #REF!?

The row or column number is larger than the range. =INDEX(A2:A6,7) asks for the seventh item of a five-cell range and returns #REF!.

How do I return a whole column with INDEX?

Use 0 as the row number: =INDEX(B2:D5,0,2) returns all of the second column. Wrap it in a function to total it, as in =SUM(INDEX(B2:D5,0,2)), or let it spill in Excel 2021 and Microsoft 365.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED