How to insert blank row after every nth row?

rjwebgraphix

Well-known Member
Joined
May 25, 2010
Messages
588
He's name Robert then? Must be a cool guy :cool:

Genetist, try this:
LOL Yes, he's a Robert too. Great minds think alike as they say.

Genetist,

Robert's last code works as expected and with using a for loop over a do loop, it'll run faster.
 

Some videos you may like

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

markus_zhang

New Member
Joined
Jan 11, 2018
Messages
3
This is what I did a few mins ago for inserting a row after every 8th, not 10th row, should work if you modify the code.

Code:
Sub SecRev()
    Dim insert_loop As Integer
    For insert_loop = 0 To 100
        Rows(9 + insert_loop * 9).EntireRow.Insert
        Cells(9 + insert_loop * 9, 1).Value = "SecRev"
        Cells(9 + insert_loop * 9, 2).Value = Cells(6 + insert_loop * 9, 2)
        Cells(9 + insert_loop * 9, 3).Value = Cells(6 + insert_loop * 9, 3)
    Next insert_loop
End Sub
Basically you have to create a 9th row, and then it gets shifted down, so instead of 17th row you need to insert 18th row, then instead of 25th row you need to insert 17th row, so on. So instead of * 8 you * 9.
 

Aniczek

New Member
Joined
Oct 24, 2018
Messages
1
hello,

This code seems to be working for me. I've never worked with VBA, so I'm excited to learn. However, I need to exclude title row, and start from row 2. I dont know how to modify the code to do it. Can you please help?
 

Watch MrExcel Video

Forum statistics

Threads
1,102,134
Messages
5,484,929
Members
407,474
Latest member
Pam Sander

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top