Share via


NamedRange.AutoFill(Range, XlAutoFillType) Method

Definition

Automatically fills the cells in the NamedRange control.

public object AutoFill (Microsoft.Office.Interop.Excel.Range Destination, Microsoft.Office.Interop.Excel.XlAutoFillType Type = Microsoft.Office.Interop.Excel.XlAutoFillType.xlFillDefault);
abstract member AutoFill : Microsoft.Office.Interop.Excel.Range * Microsoft.Office.Interop.Excel.XlAutoFillType -> obj
Public Function AutoFill (Destination As Range, Optional Type As XlAutoFillType = Microsoft.Office.Interop.Excel.XlAutoFillType.xlFillDefault) As Object

Parameters

Destination
Range

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

Type
XlAutoFillType

Specifies the fill type.Can be one of these XlAutoFillType values: xlFillDaysxlFillFormatsxlFillSeriesxlFillWeekdaysxlGrowthTrendxlFillCopyxlFillDefaultxlFillMonthsxlFillValuesxlFillYearsxlLinearTrend If this argument is xlFillDefault or omitted, Microsoft Office Excel selects the most appropriate fill type, based on the source range.

Returns

Examples

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);
}
Private Sub SetAutoRange()
    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1"), _
        "namedRange1")

    namedRange1.Value2 = 5
    namedRange1.AutoFill(Me.Range("A1", "A20"), _
        Excel.XlAutoFillType.xlFillDefault)
End Sub

Remarks

Optional Parameters

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

Applies to