Partilhar via


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)

Syntax

'Declaration
Function AutoFill ( _
    Destination As Range, _
    Type As XlAutoFillType _
) As Object
Object AutoFill(
    Range Destination,
    XlAutoFillType Type
)

Parameters

Return Value

Type: System.Object

Remarks

Optional Parameters

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

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

.NET Framework Security

See Also

Reference

NamedRange Interface

Microsoft.Office.Tools.Excel Namespace