Marco to insert rows

D

Dennis Cheung

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.
 
P

Per Jessen

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
 

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

Top