Macro to insert 10 rows on every 4th row

besucool

New Member
Joined
Aug 5, 2013
Messages
7
Hi All,

I have the below macro which works fine to insert 10 rows, but is looking at if a column is populated to do the insert. What I require is a macro that inserts 10 rows on every 4th line of the sheet regardless if the column has any text or not, preferable doing it a nth number of times. Any ideas good people? Thanks in advance

Sub InsertRowEveryXrows()


Dim x As Integer


x = 2


Do
Rows(x).Resize(9).Insert
x = x + 10
Loop Until IsEmpty(Cells(x, "A"))
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Perhaps:-
Code:
Dim x As Integer
x = 2
Do
    Rows(x).Resize(9).Insert
    x = x + 10
Loop Until x[B][COLOR=#FF0000] > 200[/COLOR][/B]
 
Upvote 0
@besucool,

Your macro does not do what you say you want for me when I try it. Just out of curiosity, does this do what you want...
Code:
Sub InsertTenRows()
  Dim R As Long, LastRow As Long
  LastRow = Cells(Rows.Count, "O").End(xlUp).Row
  For R = 2 + 4 * Int(LastRow / 4) To 2 Step -4
    Rows(R).Resize(9).Insert
  Next
End Sub
 
Upvote 0
Hi MickG,

yeap I think thats what I am looking for. I will adjust it a bit but looks goods to me. Thanks for your help.

Thanks,
Brian
 
Upvote 0
Hi MickG,

yeap I think thats what I am looking for. I will adjust it a bit but looks goods to me. Thanks for your help.
Just out of curiosity, did you try the code I posted in Message #3 ? If so, did it do what you wanted?
 
Upvote 0

Forum statistics

Threads
1,215,851
Messages
6,127,307
Members
449,374
Latest member
analystvar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top