A spreadsheet formula is an equation that performs a calculation on the numbers, functions and values of one or more cells. A formula is associated with a cell or a cell range. It is accessed using the CellRange.Formula property.
Use the CellRange.Formula property to assign a formula to a cell or each cell in a range. Refer to the Formulas example section for more information on how to create formulas.
A shared formula can be used to optimize calculations and file size. A shared formula is the equivalent of applying the same formula to a cell range. Shared formula is created automatically when you assign a formula string to an array of cells. A specified formula is associated with each cell contained within the specified cell range.
A formula is a string expression that begins with an equal (=) sign. A formula can contain the constants, operators, cell references, calls to functions, and names.
Consider the following formula, which calculates the mass of a sphere.
“4” and “3” are numeric constants. Although they are written as integers, the division operator (/) interprets them as being real numbers, i.e., 4.0 and 3.0. As a result, the calculation produces a precise result that is not rounded to an integer.
You can also calculate a formula and leave the document unchanged by using the IWorkbook.Evaluate method.
The FormulaEngine is an object that provides the capability to calculate and parse worksheet formulas. It includes a built-in formula parser, as well as the flexibility to evaluate formulas in any range of any worksheet. See the Formula Engine topic for more information.