NamedRange.RefersToR1C1 Property

Definition

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

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

Property Value

The formula that the NamedRange control is defined to refer to. The formula uses R1C1-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 refersToR1C1Range;
private void DisplayFormulaR1C1()
{
    refersToR1C1Range = this.Controls.AddNamedRange(
        this.Range["C1", "D2"], "refersToR1C1Range");
    MessageBox.Show(refersToR1C1Range.RefersTo);
    refersToR1C1Range.RefersTo = "=Sheet1!$C$3";
    refersToR1C1Range.Select();
    MessageBox.Show(refersToR1C1Range.RefersTo);
}
Private refersToR1C1Range As Microsoft.Office.Tools.Excel.NamedRange

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

Remarks

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

Applies to