ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting rows (https://www.excelbanter.com/excel-programming/397199-inserting-rows.html)

scotty

Inserting rows
 
I need a macro to insert two rows at every 6th row.

Thank you.

JW[_2_]

Inserting rows
 
Starting at which row? You can tweak something like this to your
needs.
Sub foo()
Dim n As Long
n = 6
botrow = Cells(Rows.Count, 1).End(xlUp).Row
Do Until n = botrow
Range("A1").Offset(n, 0).EntireRow.Insert
n = n + 6
botrow = botrow + 1
Loop
End Sub

Scotty wrote:
I need a macro to insert two rows at every 6th row.

Thank you.



scotty

Inserting rows
 
If I wanted to insert 5 rows for every 1 row. How would I change the below
macro?

Thanks

"JW" wrote:

Starting at which row? You can tweak something like this to your
needs.
Sub foo()
Dim n As Long
n = 6
botrow = Cells(Rows.Count, 1).End(xlUp).Row
Do Until n = botrow
Range("A1").Offset(n, 0).EntireRow.Insert
n = n + 6
botrow = botrow + 1
Loop
End Sub

Scotty wrote:
I need a macro to insert two rows at every 6th row.

Thank you.





All times are GMT +1. The time now is 11:25 PM.

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