Excel Offset Function With Examples
Excel Offset Function With Examples
Excel Offset Function With Examples
net/excel-functions/excel-offset-function
Summary
The Excel OFFSET function returns a reference to a range constructed in parts: a
starting point, a row and column offset, and a final height and width in rows and
columns. OFFSET is handy in formulas that dynamically average or sum "last n
values".
Purpose
Create a reference offset from given starting point
Return value
A cell reference.
Syntax
=OFFSET (reference, rows, cols, [height], [width])
Arguments
reference - The starting point, supplied as a cell reference or range.
rows - The number of rows to offset below the starting reference.
cols - The number of columns to offset to the right of the starting reference.
height - [optional] The height in rows of the returned reference.
width - [optional] The width in columns of the returned reference.
Usage notes
OFFSET returns a reference to a range that is offset from a starting point in a
worksheet. The starting point can be one cell or a range of cells, and the offset is
supplied as rows or columns "offset" from the starting point.
The height and width arguments are optional and determine the size of the
reference that is created.
OFFSET can be used to build a dynamic named range for charts or pivot tables, to
make sure that source data is always up to date.
https://exceljet.net/formula/sum-every-3-cells
Explanation
To write a formula that will sum "the next 3" cells each time it's copied, you can
use the OFFSET function. In the example shown, the formula in O5 is:
=SUM(OFFSET($B5,0,(COLUMN()-COLUMN($O$5))*3, 1,3))
Note: the point of this formula is to eliminate the manual task of entering ranges
manually with a single global formula, at the cost of a more complex formula.
How this formula works
At the core, the OFFSET function delivers a range of 3 cells to SUM, which
returns a summed result.
For reference we use the first cell in the data range, B5, entered as a mixed
reference (column locked, row relative).
For rows, we use 0, since we don't need to change rows.
For cols, we use the expression:
(COLUMN()-COLUMN($O$5))*3
This part of the formula figures out how many columns from the starting reference
to offset. In O5, the offset is zero, in P5, the offset is 3, and so on.
Finally, height is input as 1 and width is input as 3, since in this case we always
want a 1 x 3 range of cells.
Note: change 3 to the multiplier you need, shown as "n" in the generic form of
the formula above.
Author
Dave Bruns