The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.

How to: Add Formulas to Cells

To add a formula to a cell, use the Range.Formula property of the Cell object. Assign the required formula to this property as a string starting with the "=" sign. For more information on formulas, refer to the Spreadsheet Formulas section, and review the following examples.

When you set the Range.Formula property for the cell range, each cell in this range will contain the specified formula with adjusted cell references (all relative cell references included in the formula will automatically be changed). This approach allows you to avoid duplicating the same formula for multiple cells and manually updating cell references. Refer to the How to: Create Shared Formulas example for more information.

To perform calculations with arrays of cells, use array formulas. To create an array formula, call the Range.ArrayFormula method. Refer to the How to: Create Array Formulas example for more information.

See Also