Share via


NamedRange.RefersTo Property (2007 System)

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

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

Syntax

'Declaration
Public Property RefersTo As String
'Usage
Dim instance As NamedRange 
Dim value As String 

value = instance.RefersTo

instance.RefersTo = value
public string RefersTo { get; set; }
public:
property String^ RefersTo {
    String^ get ();
    void set (String^ value);
}
public function get RefersTo () : String 
public function set RefersTo (value : String)

Property Value

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

Remarks

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

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.

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

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace