在A栏中,我有字符串' new height'在固定间隔的单元格中:A1
,A5803
,A11605
等等,每5802行。
我想在每个单元格上方添加2391个空行,其中包含字符串' new height'。
答案 0 :(得分:0)
我在excel-forum上得到了Olly的回答并且有效 -
Sub foo()
Const lRows As Long = 2391
Const sText As String = "new height"
Dim s() As String
Dim i As Integer
Application.ScreenUpdating = False
With ActiveSheet
.AutoFilterMode = False
.Range("A:A").AutoFilter field:=1, Criteria1:=sText
s = Split(.AutoFilter.Range.SpecialCells(xlCellTypeVisible).Address, ",")
.AutoFilterMode = False
For i = UBound(s) To LBound(s) Step -1
.Range(s(i)).Resize(lRows, 1).EntireRow.Insert
Next i
End With
Application.ScreenUpdating = True
End Sub