We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

NamedRange.FormulaLabel Property

Gets or sets the formula label type for the NamedRange control.

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

XlFormulaLabel FormulaLabel { get; set; }

The return value of this property can be xlNone if the NamedRange control contains no labels, or one of the following XlFormulaLabel values:

The following code example uses the FormulaLabel property to specify that column labels can be used in formulas, and then creates a formula that uses a column label in a NamedRange.

This example is for a document-level customization.

private void ShowFormulaLabel()
    Globals.ThisWorkbook.AcceptLabelsInFormulas = true;

    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A4"],
    namedRange1.FormulaLabel =

    this.Range["A1", missing].Value2 = "Product Sales";
    this.Range["A2", missing].Value2 = 11;
    this.Range["A3", missing].Value2 = 22;
    this.Range["A4", missing].Formula = "=Sum(Product Sales)";