Formualizer Docs

OFFSET

Returns a reference shifted from a starting reference by rows and columns.

OFFSET is volatile and returns a reference that can point to a single cell or a resized range, depending on the optional height and width arguments.

The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.

Syntax

=OFFSET(reference, rows, cols, [height], [width])

Arguments

ArgumentTypeRequiredDefault
referencerange (range)Required—
rowsnumberRequired—
colsnumberRequired—
heightnumberOptional—
widthnumberOptional—

Return type

Can return a reference when evaluated in a reference context.

Remarks

  • rows and cols shift from the top-left of reference.
  • If omitted, height and width default to the original reference size.
  • Offset/size inputs coerce like Excel: a blank is 0, TRUE is 1 and numeric text is parsed; other text returns #VALUE!.
  • In value context, a 1x1 result returns a scalar; larger results spill as an array.

Error cases

  • Non-positive target coordinates or dimensions return #REF!, and so does a result that extends past the last row or column of the sheet.

Examples

Move one row down and one column right from the anchor.

Formula =OFFSET(A1,1,1)

Input cells
B
242

Expected result 42

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Supply the height and width to sum a two-row offset range.

Formula =SUM(OFFSET(A1,1,0,2,1))

Input cells
A
220
330

Expected result 50

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Zero offsets leave the reference anchored at the input cell.

Formula =OFFSET(A1,0,0)

Input cells
A
110

Expected result 10

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Moving above the first row creates an invalid reference.

Formula =OFFSET(A1,-1,0)

Expected result #REF!

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Offset and resize a range

Formula =SUM(OFFSET(A1,1,0,2,2))

Input cells
AB
225
336

Expected result 16

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

FAQ

What defaults are used when height and width are omitted?

OFFSET keeps the source reference size, then applies the row/column shift to that same-sized block.

When does OFFSET return #REF!?

It returns #REF! if the shifted start goes to row/column <= 0, if requested height/width are non-positive, or if the result extends past the edge of the sheet.

Implementation

Engine source

On this page