Going Stellar

Home/Google Sheets reference

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

ArgumentTypeRequiredWhat it does
cell_referencerangeyesThe starting cell or range.
offset_rowsnumberyesRows to move down, or up when negative.
offset_columnsnumberyesColumns to move right, or left when negative.
heightnumbernoRows in the returned range.
widthnumbernoColumns in the returned range.

Examples

The examples use this table, starting in A1:

MonthSalesCost
Jan10060
Feb12070
Mar9050
Apr15080
May13075
=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:

10060
12070

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.

Sources

  1. OFFSET (Docs Editors Help)

Markdown version · All functions