ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   INSERT ROWS (https://www.excelbanter.com/excel-programming/404927-insert-rows.html)

pmss

INSERT ROWS
 
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

ryguy7272

INSERT ROWS
 
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 he
http://www.mvps.org/dmcritchie/excel/insrtrow.htm


Regards,
Ryan--

--
RyGuy


"pmss" wrote:

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


pmss

INSERT ROWS
 
Thank you

"ryguy7272" wrote:

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 he
http://www.mvps.org/dmcritchie/excel/insrtrow.htm


Regards,
Ryan--

--
RyGuy


"pmss" wrote:

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



All times are GMT +1. The time now is 05:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com