Condividi tramite


NamedRange.RefersToRange Property

Definition

Gets the Range referred to by a NamedRange control.

public:
 property Microsoft::Office::Interop::Excel::Range ^ RefersToRange { Microsoft::Office::Interop::Excel::Range ^ get(); };
public Microsoft.Office.Interop.Excel.Range RefersToRange { get; }
member this.RefersToRange : Microsoft.Office.Interop.Excel.Range
Public ReadOnly Property RefersToRange As Range

Property Value

A Range referred to by a NamedRange control.

Examples

The following code example starts a series of day names and then creates a NamedRange to contain the series. It then uses the AutoFill method to complete the series. AutoFill requires a Microsoft.Office.Interop.Excel.Range as a parameter.

This example is for a document-level customization.

private void AutoFillRange()
{
    this.Range["A1"].Value2 = "Sunday";
    this.Range["A2"].Value2 = "Monday";
    Microsoft.Office.Tools.Excel.NamedRange dayRange
        = this.Controls.AddNamedRange(this.Range["A1", "A7"], 
        "dayRange");
    this.Range["A1", "A2"].AutoFill(dayRange.RefersToRange,
        Excel.XlAutoFillType.xlFillDays);
}
Private Sub AutoFillRange()
    Me.Range("A1").Value2 = "Sunday"
    Me.Range("A2").Value2 = "Monday"
    Dim dayRange As Microsoft.Office.Tools.Excel.NamedRange = _
        Me.Controls.AddNamedRange(Me.Range("A1", "A7"), _
        "dayRange")
    Me.Range("A1", "A2").AutoFill(dayRange.RefersToRange, _
        Excel.XlAutoFillType.xlFillDays)
End Sub

Remarks

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

Applies to