【发布时间】:2015-03-12 10:31:16
【问题描述】:
我有一个宏,可以在电子表格中插入一些行,这些行数由用户输入对话框来规定。我想要实现的是根据用户插入的行数将公式自动填充到相应的列中。
我目前的代码是:
Dim iInputRows As Integer
Dim iCount
iInputRows = CInt(InputBox("How many data entry rows required?")) 'message box for user input (interger)
If iInputRows > 1 Then
For iCount = 1 To iInputRows - 1
Rows(iCount + 13 & ":" & iCount + 13).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove 'insert no. of rows from from first row (row 13) to user input minus 1 (this ensures that the exact no. of rows are inserted from row 13 down)
Range("D" & iCount + 13).Value = iCount + 1 'column D is used for sequential numbering purposes
Next iCount
End If
自动填充的公式是= X13:AR13。
我对自动填充公式比较满意,但我在此应用程序中难以根据规定的行数停止自动填充。
【问题讨论】:
标签: vba excel excel-formula autofill