Insert blank row after every 11th row.

C

Captain Snuggles

I've found some vb code that kind of does what I need, but every time
I tweak the code to have it insert the blank row after each 11th row
it doesn't work. Any ideas?

Row 1 | Column Header
Row 2 | Value 1
Row 3 | Value 2
Row 4 | Value 3
Row 5 | Value 4
Row 6 | Value 5
Row 7 | Value 6
Row 8 | Value 7
Row 9 | Value 8
Row 10 | Value 9
Row 11 | Value 10
Row 12 | Value 11
Row 12 | BLANK ROW
Row 13 | Value 12...and so on and so forth.
 
C

Captain Snuggles

Here's what I found originally:

Sub Insert_Blank_Rows()

'Select last row in worksheet.
Selection.End(x1Down).Select

Do Until ActiveCell.Row = 1
'Insert blank row.
ActiveCell.EntireRow.Insert shift:=x1Down
'Move up one row.
ActiveCell.Offset(-1, 0).Select
Loop

End Sub

Then there was a post saying to change x(one)down to x(ell)down. I
did that, but I wasn't able to figure out how to tell it to do this
every 11th row. I changed the 1's to 11's, but that didn't work. I
keep getting an application-defined or object-defined error.
 
D

Don Guillett

Work from the bottom up

Sub insertrowat()
rowstoinsert = 3
lr = Cells(Rows.Count, "a").End(xlUp).Row
For i = lr To rowstoinsert + 1 Step -rowstoinsert
Rows(i).Insert
Next i
End Sub
 
C

Captain Snuggles

If I work from the bottom up it doesn't work right. How do I make it
go from top down?
 
D

Don Guillett

try it this way

Sub insertrow()
nr = 5
i = nr
Do While Cells(i, "a") <> ""
Cells(i, "a").EntireRow.Insert
i = i + nr
Loop
End Sub
 
G

Guest

this is primitive but it should do what you want:

Sub ElevRowBlnk()
Range("$A$12").Activate
Do Until ActiveCell = ""
ActiveCell.EntireRow.Insert
ActiveCell.Offset(12, 0).Activate
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top