Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert row every X rows in excel

I have a long list of codes such as 008.45, etc that will need multiple lines of text to explain them. I have the list of codes and I would like to know how I can automatically insert a row every, say, fifth row. Example Below

1          
2
3
4
5
6
7
8
9
10...
100

Every five rows I would like to insert a given number of my choosing of rows. How can I do this? Thanks

like image 891
dzilla Avatar asked Feb 26 '23 02:02

dzilla


1 Answers

Test with a range from row 1 to row 100.

Sub InsertRows()
For i = Sheet1.UsedRange.Rows.Count To 1 Step -5
    For j = 0 To 4
        Sheet1.Rows(i).Insert
    Next
Next
End Sub
like image 52
Fionnuala Avatar answered Mar 03 '23 18:03

Fionnuala