我有一個宏在電子表格中插入一行,我希望它自動填充新插入行中的公式。使用VBA插入行並自動填充
這裏是我電子表格中的一個例子。
編輯:在我目前的電子表格中有10列和幾行,但波紋管我只是複製一列
ColumnB
TextA
TextA
TextA
TextA
TextB
TextB
TextB
TextB
TextC
TextC
TextC
TextC
下面的代碼後TextA
,TextB
,TextC
上
Sub Insert()
Dim LastRow As Long
Dim Cell As Range
Application.ScreenUpdating = False
LastRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(-4162).Row
For Each Cell In Sheets("Sheet1").Range("B7:B" & LastRow)
If Cell.Value <> Cell.Offset(1, 0) Then
If Cell.Value <> "" Then
Sheets("Sheet1").Rows(Cell.Row + 1).Insert
End If
End If
Next Cell
Application.ScreenUpdating = True
End Sub
有沒有辦法自動填充公式?
我想在我的循環內插入一行代碼,如下所示,在添加新行之後。這個問題是Range
的論點。我不知道該怎麼指定它
Selection.AutoFill Destination:=Range("A21:J22"), Type:=xlFillDefault
添加類似範圍(小區,cell.offset(1,0)) –