Freigeben über


NamedRange.RefersTo Property

Definition

Gets or sets the formula that the NamedRange control is defined to refer to, using A1-style notation.

public:
 property System::String ^ RefersTo { System::String ^ get(); void set(System::String ^ value); };
public string RefersTo { get; set; }
member this.RefersTo : string with get, set
Public Property RefersTo As String

Property Value

The formula that the NamedRange control is defined to refer to. The formula uses A1-style notation and begins with an equal sign.

Examples

The following code example creates a NamedRange and displays the formula for the NamedRange. It then assigns a new cell to the NamedRange and displays the new formula.

This example is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange refersToRange;
private void DisplayFormula()
{
    refersToRange = this.Controls.AddNamedRange(
         this.Range["C1", "D2"], "refersToRange");
    MessageBox.Show(refersToRange.RefersTo);
    refersToRange.RefersTo = "=Sheet1!$C$3";
    refersToRange.Select();
    MessageBox.Show(refersToRange.RefersTo);
}
Private refersToRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub DisplayFormula()
    refersToRange = Me.Controls.AddNamedRange( _
        Me.Range("C1", "D2"), "refersToRange")
    MessageBox.Show(refersToRange.RefersTo)
    refersToRange.RefersTo = "=Sheet1!$C$3"
    refersToRange.Select()
    MessageBox.Show(refersToRange.RefersTo)
End Sub

Remarks

Use the RefersTo property to change the range that a NamedRange control refers to.

Applies to