Solved Need help from somebody skilled in VBA code in Xcel

May 3, 2012 at 12:21:27
Specs: Windows 7
I have thousands of rows. Need to insert two consecutive blank rows after every four filled rows by auto generation rather than manual which will take ages.

See More: Need help from somebody skilled in VBA code in Xcel

Report •

#1
May 3, 2012 at 14:08:32
✔ Best Answer
This is quick and dirty.

I suggest that you try it in a backup copy of your workbook in case things go terribly wrong.


Sub TwoByFour()
'Determine last row with data in Column A
  lastRw = Range("A" & Rows.Count).End(xlUp).Row
'Increase Row counter by the number of rows divided by 2
  lastCount = lastRw + lastRw / 2
'Loop through rows, inserting 2 after every 4
   For rw = 5 To lastCount Step 6
     Cells(rw, 1).EntireRow.Insert
     Cells(rw, 1).EntireRow.Insert
   Next
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •
Related Solutions


Ask Question