Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

NamedRange.AutoFill Method

Automatically fills the cells in the NamedRange control.

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

Object AutoFill(
	Range Destination,
	XlAutoFillType Type
)

Parameters

Destination
Type: Microsoft.Office.Interop.Excel.Range

The cells to be filled. The destination must include the source range.

Type
Type: Microsoft.Office.Interop.Excel.XlAutoFillType

Specifies the fill type.

Can be one of these XlAutoFillType values:

xlFillDays

xlFillFormats

xlFillSeries

xlFillWeekdays

xlGrowthTrend

xlFillCopy

xlFillDefault

xlFillMonths

xlFillValues

xlFillYears

xlLinearTrend

If this argument is xlFillDefault or omitted, Microsoft Office Excel selects the most appropriate fill type, based on the source range.

Return Value

Type: System.Object

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example sets the value 5 in cell A1, and then uses the AutoFill method to automatically fill cells A1 through A20 with the value in cell A1.

This example is for a document-level customization.

private void SetAutoRange()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1"],
        "namedRange1");

    namedRange1.Value2 = 5;
    namedRange1.AutoFill(this.Range["A1", "A20"],
        Excel.XlAutoFillType.xlFillDefault);
}

Show:
© 2015 Microsoft