Expand Minimize

NamedRange.Calculate Method

Calculates the values of cells in a NamedRange control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Object Calculate()

Return Value

Type: System.Object

The following code example sets the Formula property of a NamedRange control to calculate the sum of cells A1 through A5, uses the FormulaHidden property to hide the formula, and then calls the Calculate method to calculate the sum of the cells and place the sum in cell A6.

This example is for a document-level customization.

private void CalculateRange()
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A5"],

    Microsoft.Office.Tools.Excel.NamedRange namedRange2 =
        this.Controls.AddNamedRange(this.Range["A6", missing],

    namedRange1.Value2 = 5;
    namedRange2.Formula = "=SUM(A1:A5)";
    namedRange2.FormulaHidden = true;

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft