下面的vba代码(从here修改)将在E列中任何值为“0”的行上方插入一个空行而不是插入一个空行,是否有办法复制用“0”行并将其插入上方?可以修改此vba代码来执行此操作吗?
Sub BlankLine()
Dim Col As Variant
Dim BlankRows As Long
Dim LastRow As Long
Dim R As Long
Dim StartRow As Long
Col = "E"
StartRow = 1
BlankRows = 1
LastRow = Cells(Rows.Count, Col).End(xlUp).Row
Application.ScreenUpdating = False
With ActiveSheet
For R = LastRow To StartRow + 1 Step -1
If .Cells(R, Col) = "0" Then
.Cells(R, Col).EntireRow.Insert Shift:=xlDown
End If
Next R
End With
Application.ScreenUpdating = True
End Sub
答案 0 :(得分:2)
只需添加此行
即可.Cells(R, Col).EntireRow.Copy
在.Insert
行之前