INDEX
About this lesson
INDEX returns the value at a position inside a range. The third cell down a column, or the cell in row 2, column 3 of a block.
- fetch the value at a position in a column with INDEX.
- fetch a cell from a block by its row and column inside the block.
- say why INDEX(A1:D4,2,2) and INDEX(B2:D4,2,2) are different cells.
The idea
On its own it looks useless, because you must already know the position. That is the idea: it is one half of a pair. INDEX turns a position into a value. MATCH turns a value into a position. Together they do everything VLOOKUP does, without its two limits.
Learn INDEX by itself first, because the counting rule catches people later. The numbers are positions inside the range you gave it, not row and column numbers on the sheet. Give it B2:D4 and position 1,1 is B2, not A1.
The mistake to watch for
A block that starts one row or column away from the data. INDEX counts positions inside the range you gave it, not on the sheet. So a block that starts one row early shifts every answer by one, with no error. When INDEX returns the cell next to the one you wanted, check where the block starts.
Read more about this
Where this comes up again
This lesson needs JavaScript to run. Everything below is the lesson in full, but you cannot type into the grid or be marked.
INDEX returns whatever sits at a position inside a range. Given a single column, it needs one number: how far down.
In F2, type:
=INDEX(B2:B4,3)
B2:B4 is Monday's column, 3 the third cell down.
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Van | Mon | Tue | Wed | |||
| 2 | Van 1 | Ola | Ola | Sam | |||
| 3 | Van 2 | Jo | Ravi | Ravi | |||
| 4 | Van 3 | Sam | Jo | Ola | |||
| 5 | |||||||
| 6 | |||||||
| 7 | |||||||
| 8 |
Every step
-
INDEXreturns whatever sits at a position inside a range. Given a single column, it needs one number: how far down. InF2, type:=INDEX(B2:B4,3).B2:B4is Monday's column, 3 the third cell down. -
Read
=INDEX(C2:C4,2)and say who it returns. That is Tuesday's column, second cell down. -
For a block,
INDEXneeds two numbers: how far down, then how far across. Both count from the block's top-left cell. InF3, find who is on Van 2 on Tuesday. Shape:=INDEX(range,row,col). Use the blockB2:D4: row 2, column 2. -
In
F4, find who is on Van 1 on Wednesday, from the same block. -
A range one row tall works like a column turned sideways: the one number counts across. In
F5, find the third name along Van 3's row,B4:D4. -
The trap:
INDEXcounts inside the range, not on the sheet. Read=INDEX(A1:D4,2,2)and say who it returns. The block now starts atA1, one row up and one column left.