Google Sheets function · Lookup
OFFSET in Google Sheets: syntax and examples
OFFSET starts at a reference, moves by a number of rows and columns, and returns that cell or a range of the height and width you give. It is useful for ranges whose size depends on a count, such as the last N rows.
Syntax
OFFSET(cell_reference, offset_rows, offset_columns, [height], [width])
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
cell_reference | range | yes | The starting cell or range. |
offset_rows | number | yes | Rows to move down, or up when negative. |
offset_columns | number | yes | Columns to move right, or left when negative. |
height | number | no | Rows in the returned range. |
width | number | no | Columns in the returned range. |
Examples
The examples use this table, starting in A1:
| Month | Sales | Cost |
| Jan | 100 | 60 |
| Feb | 120 | 70 |
| Mar | 90 | 50 |
| Apr | 150 | 80 |
| May | 130 | 75 |
=OFFSET(A1, 2, 1)Result: 120
Start at A1, move 2 rows down and 1 column right: the cell B3.
Run in a Google Sheet (English US locale) on .
=SUM(OFFSET(B1, 1, 0, 3, 1))Result: 310
A range 3 rows high starting under B1: B2:B4.
Run in a Google Sheet (English US locale) on .
=OFFSET(A1, 1, 1, 2, 2)Result:
| 100 | 60 |
| 120 | 70 |
A 2 by 2 block starting at B2. The result spills into neighbouring cells.
Run in a Google Sheet (English US locale) on .
=SUM(OFFSET(B1, COUNTA(B:B)-3, 0, 3, 1))Result: 370
The last three values of a growing column.
Run in a Google Sheet (English US locale) on .
=ROWS(OFFSET(A1, 0, 0, 3, 2))Result: 3
Height of the range OFFSET builds.
Run in a Google Sheet (English US locale) on .
Common errors
- Moving outside the sheet, for example up from row 1, returns #REF!.
- A height or width of 0 returns #VALUE!. Use at least 1.
- Typed alone in a cell, OFFSET with a height and width spills a block of values, so leave empty cells to its right and below.
- The offsets count from the starting cell, not from the corner of the range, so OFFSET(A1, 1, 1) is B2.
Compared with Excel
Same syntax in Excel.