Udostępnij za pośrednictwem


NamedRange.FormulaLabel Property (2007 System)

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

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public Property FormulaLabel As XlFormulaLabel
'Usage
Dim instance As NamedRange 
Dim value As XlFormulaLabel 

value = instance.FormulaLabel

instance.FormulaLabel = value
[BrowsableAttribute(false)]
public XlFormulaLabel FormulaLabel { get; set; }
[BrowsableAttribute(false)]
public:
property XlFormulaLabel FormulaLabel {
    XlFormulaLabel get ();
    void set (XlFormulaLabel value);
}
public function get FormulaLabel () : XlFormulaLabel 
public function set FormulaLabel (value : XlFormulaLabel)

Property Value

Type: XlFormulaLabel
One of the XlFormulaLabel values.

Remarks

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

Examples

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 Sub ShowFormulaLabel()
    Globals.ThisWorkbook.AcceptLabelsInFormulas = True 

    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1", "A4"), _
        "formualArrayRange")
    namedRange1.FormulaLabel = Excel.XlFormulaLabel.xlColumnLabels

    Me.Range("A1").Value2 = "Product Sales" 
    Me.Range("A2").Value2 = 11
    Me.Range("A3").Value2 = 22
    Me.Range("A4").Formula = "=Sum(Product Sales)" 
End Sub
private void ShowFormulaLabel()
{
    Globals.ThisWorkbook.AcceptLabelsInFormulas = true;

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

    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)";
}

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace