Expand Minimize

NamedRange.RefersToRange Property

Gets the Microsoft.Office.Interop.Excel.Range referred to by a NamedRange control.

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

Range RefersToRange { get; }

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

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft