Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Marco to insert rows

Dear all,

Can someone help for a Marco describe as following.

a data table, sheet 1, data range from A1 to M100.
A1 to M1 is the heading of the table.
A2 to M100 is data.

I need a marco to insert single rows between row 2 to row 100, they are
single row between each row, i.e. insert a row between row 2 and row 3, then
insert a row between row 3 and row 4.
then copy A1 to M1 to every new rows.
And number of rows is variable, it means 100 rows this time and may be 110
rows next time.

thanks for your help.

--
Dennis Cheung
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Marco to insert rows

Hi

Try this:

Sub aaa()
Dim LastRow As Long
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For r = LastRow To 3 Step -1
Range("A" & r).EntireRow.Insert
Next
Range("A1:M1").Copy
For r = 3 To (LastRow - 1) * 2 Step 2
Range("A" & r).PasteSpecial xlPasteAll
Next
Application.CutCopyMode = False
End Sub

Regards,
Per

On 4 Sep., 04:23, Dennis Cheung
wrote:
Dear all,

Can someone help for a Marco describe as following.

a data table, sheet 1, data range from A1 to M100.
A1 to M1 is the heading of the table.
A2 to M100 is data.

I need a marco to insert single rows between row 2 to row 100, they are
single row between each row, i.e. insert a row between row 2 and row 3, then
insert a row between row 3 and row 4. *
then copy A1 to M1 to every new rows.
And number of rows is variable, it means 100 rows this time and may be 110
rows next time.

thanks for your help.

--
Dennis Cheung


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Marco to insert rows

it works and very helpful. thanks!
--
Dennis Cheung


"Per Jessen" wrote:

Hi

Try this:

Sub aaa()
Dim LastRow As Long
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For r = LastRow To 3 Step -1
Range("A" & r).EntireRow.Insert
Next
Range("A1:M1").Copy
For r = 3 To (LastRow - 1) * 2 Step 2
Range("A" & r).PasteSpecial xlPasteAll
Next
Application.CutCopyMode = False
End Sub

Regards,
Per

On 4 Sep., 04:23, Dennis Cheung
wrote:
Dear all,

Can someone help for a Marco describe as following.

a data table, sheet 1, data range from A1 to M100.
A1 to M1 is the heading of the table.
A2 to M100 is data.

I need a marco to insert single rows between row 2 to row 100, they are
single row between each row, i.e. insert a row between row 2 and row 3, then
insert a row between row 3 and row 4.
then copy A1 to M1 to every new rows.
And number of rows is variable, it means 100 rows this time and may be 110
rows next time.

thanks for your help.

--
Dennis Cheung



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: Formats & formulas extended to additonal rows Twishlist Excel Worksheet Functions 0 October 22nd 07 04:23 AM
Marco to delete all rows except those containing 'MZ' in string [email protected] Excel Programming 6 April 3rd 07 06:46 PM
marco to delete rows Johnfli Excel Discussion (Misc queries) 2 January 11th 07 04:50 PM
marco that inserts rows? lloydyleg11 Excel Worksheet Functions 3 August 7th 06 12:37 AM
marco that inserts rows? lloydyleg11 Excel Worksheet Functions 0 August 3rd 06 04:54 AM


All times are GMT +1. The time now is 02:33 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"