Search code examples
excelexcel-2007vba

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


Solution

  • You would need to use a loop as below:

    for i=1 to 100 step 1
      if i mod 5 = 0 then
         // Insert the rows
      end if
    next i