Vous êtes sur la page 1sur 4

https://exceljet.

net/excel-functions/excel-offset-function

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.

 OFFSET only returns a reference, no cells are moved.


 Both rows and cols can be supplied as negative numbers to reverse their normal
offset direction - negative cols offset to the left, and negative rows offset above.
 OFFSET is a "volatile" formula; it is recalculated whenever there is any change to
a worksheet. It can slow down Excel in a complicated worksheet.
 OFFSET will display the #REF! error value if the offset is outside the edge of the
worksheet.
 When height or width is omitted, the height and width of reference is used.
 OFFSET can be used with any other function that expects to receive a reference.

OFFSET formula examples

https://exceljet.net/formula/sum-every-3-cells

Sum every 3 cells


Generic formula
=SUM(OFFSET(first,0,(COLUMN()-COLUMN(current))*n, 1,n))

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.

The arguments for OFFSET are provided as follows:

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

Vous aimerez peut-être aussi