insert 2 rows and copy and paste

S

steveo

I came across this macro to insert, copy and paste a row. Is there a
way to modify it to insert, copy and paste 2 rows?

Sub AddRows()
Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 1 Step -1
Rows(i + 1).Insert
Rows(i + 1).FillDown
Next
End Sub
 
D

Dave Peterson

Maybe...

Option Explicit
Sub Add2Rows()
Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 1 Step -1
Rows(i + 1).Resize(2).Insert
Rows(i).Resize(3).FillDown
Next i
End Sub
 
S

steveo

Maybe...

Option Explicit
Sub Add2Rows()
Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 1 Step -1
Rows(i + 1).Resize(2).Insert
Rows(i).Resize(3).FillDown
Next i
End Sub

steveowrote:

Thank you Dave. This works well for me.
 

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