For example, if I need 5 of my records between my data lines, I would use Mod 6, however you need to allow these new lines, as they will affect the range of ranges used! To do this, you will need to add the number of rows that will be inserted into the length of the loop (for example, the absolute value (numberOfRows / YourModValue)).
Code for this:
Sub InsertRows() For i = 1 To Sheet1.UsedRange.Rows.Count + Abs(Sheet1.UsedRange.Rows.Count / 6) Step 1 If i Mod 6 = 0 Then Sheet1.Rows(i).Insert Cells(i, 1).Value = "Whatever data you want in your new separator cell" End If Next i End Sub
source share