I'm using the following code:
Sub del_row()
Dim r As Long, y As Long
y = Sheet1.Range("A" & Sheet1.Rows.Count).End(xlUp).Row
For r = 2 To y Step 2
Rows(r).Insert Shift:=xlDown
Next r
End Sub
This works, but stops at row 1020 and I'm not sure why. Is there a way I can modify this to continue until there is no more data?
If you are inserting or deleting rows, work from the bottom up.
Sub del_row()
Dim r As Long, y As Long
y = Sheet1.Range("A" & Sheet1.Rows.Count).End(xlUp).Row
For r = y To 2 Step -1 '<~~ this is the magic
Sheet1.cells(r, 1).entirerow.Insert Shift:=xlDown
Next r
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.