如何更改下面的代码添加两行?
如何更改下面的代码添加2行?
Sub AddRows() Dim MyRange As Range Dim iCounter As Long Dim LastRow As Long With ThisWorkbook.Worksheets("Numbers") LastRow = .Range("A" & .Rows.Count).End(xlUp).Row Set MyRange = Range("A2:A" & LastRow) For iCounter = MyRange.Rows.Count To 2 Step -1 'Insert blank row, MyRange.Rows(iCounter).EntireRow.Insert Next iCounter End With End Sub
如果你打算插入两行(见加里的评论),你可以做一个快速的改变:
MyRange.Rows(iCounter).EntireRow.Insert
至
MyRange.Rows(iCounter).Resize(2,1).EntireRow.Insert