Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
insert 2 rows and copy and paste
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
insert 2 rows and copy and paste
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 steveo wrote: 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 -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
insert 2 rows and copy and paste
On May 18, 5:59 pm, Dave Peterson wrote:
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: 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 -- Dave Peterson Thank you Dave. This works well for me. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
check box, copy / paste or insert / delete row | Excel Worksheet Functions | |||
Copy and paste versus copy and insert copied cells | New Users to Excel | |||
Insert Rows & Paste Link | Excel Programming | |||
Hide Rows - copy and paste only rows that show | Excel Worksheet Functions | |||
Copy Rows and insert these rows before a page break | Excel Programming |