INSERT ROWS

  • Thread starter Thread starter pmss
  • Start date Start date
P

pmss

hello

Can somebody write me a code to insert some rows after certain rows. i have
data like this
1
5
6
6
8
10
12
....
....
i have to insert 2 number of rows in every 3 data interval. Means i have to
insert 2 rows after 6 and 12 and so on upto end.

thanks
 
This will give you a little more control over the number of rows that are
inserted:
Sub InsertBlankRows()
'-- Ken Wright, 2003-08-09
Application.ScreenUpdating = False
Dim numRows As Long
Dim r As Long
Dim Rng As Range
Dim lastrw As Long
numRows = InputBox("How many Rows")
lastrw = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range(Cells(1, "A"), Cells(lastrw, "A"))
For r = Rng.Rows.Count To 1 Step -3
Rng.Rows(r + 1).Resize(numRows).EntireRow.Insert
Next r
Application.ScreenUpdating = True
End Sub


Found the macro here:
http://www.mvps.org/dmcritchie/excel/insrtrow.htm


Regards,
Ryan--
 
Thank you

ryguy7272 said:
This will give you a little more control over the number of rows that are
inserted:
Sub InsertBlankRows()
'-- Ken Wright, 2003-08-09
Application.ScreenUpdating = False
Dim numRows As Long
Dim r As Long
Dim Rng As Range
Dim lastrw As Long
numRows = InputBox("How many Rows")
lastrw = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range(Cells(1, "A"), Cells(lastrw, "A"))
For r = Rng.Rows.Count To 1 Step -3
Rng.Rows(r + 1).Resize(numRows).EntireRow.Insert
Next r
Application.ScreenUpdating = True
End Sub


Found the macro here:
http://www.mvps.org/dmcritchie/excel/insrtrow.htm


Regards,
Ryan--
 

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

Back
Top