ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   loop to insert rows (https://www.excelbanter.com/excel-programming/313765-loop-insert-rows.html)

fergie

loop to insert rows
 
I need code for a loop that will insert a row (above) then go to the next row
and insert a row. I have code to insert rows however, I get into an infinite
loop.

Thanks!

James W.

loop to insert rows
 
This might be what your looking for

Sub InsertRows()
Dim cRows As Long
Dim i As Integer

For i = Cells(Rows.Count, "A").End(xlUp).row To 2 Step -1
If Cells(i, "A") < "" And Cells(i - 1, "A") < "" Then
Cells(i, "A").EntireRow.Insert
End If
Next i
End Sub

"Fergie" wrote:

I need code for a loop that will insert a row (above) then go to the next row
and insert a row. I have code to insert rows however, I get into an infinite
loop.

Thanks!



All times are GMT +1. The time now is 09:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com