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
Destination
Type: Microsoft.Office.Interop.Excel.RangeThe cells to be filled. The destination must include the source range.
Type
Type: Microsoft.Office.Interop.Excel.XlAutoFillTypeSpecifies the fill type.
Can be one of these XlAutoFillType values:
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
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.