As does Microsoft Excel, Apache OpenOffice calc provides an
offset
function that allows
you to calculate a value based on the contents of a cell that is a specified
distance in rows and columns from a particular cell. The syntax for calc is
as follows:
OFFSET
Returns the value of a cell offset by a certain number of rows and columns from a given reference point.
Syntax
OFFSET(Reference; Rows; Columns; Height; Width)
Reference is the reference from which the function searches for the new reference.
Rows is the number of rows by which the reference was corrected up (negative value) or down.
Columns (optional) is the number of columns by which the reference was corrected to the left (negative value) or to the right.
Height (optional) is the vertical height for an area that starts at the new reference position.
Width (optional) is the horizontal width for an area that starts at the new reference position.
Arguments Rows and Columns must not lead to zero or negative start row or column.
Arguments Height and Width must not lead to zero or negative count of rows or columns.
In the OpenOffice Calc functions, parameters marked as "optional" can be left out only when no parameter follows. For example, in a function with four parameters, where the last two parameters are marked as "optional", you can leave out parameter 4 or parameters 3 and 4, but you cannot leave out parameter 3 alone.Example
=OFFSET(A1;2;2) returns the value in cell C3 (A1 moved by two rows and two columns down). If C3 contains the value 100 this function returns the value 100.
=OFFSET(B2:C3;1;1) returns a reference to B2:C3 moved down by 1 row and one column to the right (C3:D4).
=OFFSET(B2:C3;-1;-1) returns a reference to B2:C3 moved up by 1 row and one column to the left (A1:B2).
=OFFSET(B2:C3;0;0;3;4) returns a reference to B2:C3 resized to 3 rows and 4 columns (B2:E4).
=OFFSET(B2:C3;1;0;3;4) returns a reference to B2:C3 moved down by one row resized to 3 rows and 4 columns (B2:E4).
=SUM(OFFSET(A1;2;2;5;6)) determines the total of the area that starts in cell C3 and has a height of 5 rows and a width of 6 columns (area=C3:H7).
[ More Info ]