范围。自动填充方法 (Excel)Range.AutoFill method (Excel)

对指定区域中的单元格执行自动填充。Performs an autofill on the cells in the specified range.

语法Syntax

expressionexpression. AutoFill( _Destination_ , _Type_ )

expression 一个表示 Range 对象的变量。expression A variable that represents a Range object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
DestinationDestination 必需Required RangeRange 要填充的单元格。目标区域必须包括源区域。The cells to be filled. The destination must include the source range.
TypeType 可选Optional XlAutoFillTypeXlAutoFillType 指定填充类型。Specifies the fill type.

返回值Return value

VariantVariant

示例Example

本示例以工作表 Sheet1 上的单元格区域 A1:A2 为基础,对单元格区域 A1:A20 进行自动填充。This example performs an autofill on cells A1:A20 on Sheet1, based on the source range A1:A2 on Sheet1. 运行此示例之前, 请在单元格 A1 中键入1 , 并在单元格 A2 中键入2Before running this example, type 1 in cell A1 and type 2 in cell A2.

Set sourceRange = Worksheets("Sheet1").Range("A1:A2") 
Set fillRange = Worksheets("Sheet1").Range("A1:A20") 
sourceRange.AutoFill Destination:=fillRange

另请参阅See also

Range 对象Range Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.