#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert rows in a worksheet that do not change adjoining rows craigandmel Excel Discussion (Misc queries) 2 April 29th 08 10:26 PM
VBA to count rows from specific cell and insert rows Valerie Excel Programming 3 November 26th 07 10:14 PM
Insert rows: Formats & formulas extended to additonal rows Twishlist Excel Worksheet Functions 0 October 22nd 07 04:23 AM
Insert page breaks every 50 rows but do not include hidden rows Martin[_21_] Excel Programming 5 March 12th 07 05:10 PM
Copy Rows and insert these rows before a page break AQ Mahomed Excel Programming 0 June 8th 04 09:09 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"