If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
macro to insert rows and copy and paste
Here is a macro that a gentleman created for me and I need
the macro to copy and paste all 5 columns down, and also it is inserting the number of rows in column D which is great but I need it to subtract one row from column D value. Example of spreadsheet is customer order# item quantity date price steve 100001 pepsi 3 06/03/04 10.00 jack 100002 coke 8 06/01/04 25.00 To insert rows and copy down Sub insertXrows_copydn() On Error Resume Next For i = 16 To 2 Step -1 x = Cells(i, "d") Y = Cells(i, "a") Cells(i, "a").Resize(x, 1).EntireRow.Insert Cells(i, "a").Resize(x, 1).Value = Y Next i End Sub thanks a bunch |
#2
|
|||
|
|||
macro to insert rows and copy and paste
Steve,
I think this is what you are looking for: Sub insertXrows_copydn() On Error Resume Next For i = 16 To 2 Step -1 X = Cells(i, "d") - 1 Y = Range(Cells(i, 1), Cells(i, 6)).Value Cells(i, "a").Resize(X, 1).EntireRow.Insert Cells(i, "a").Resize(X, 6).Value = Y Next i End Sub -----Original Message----- Here is a macro that a gentleman created for me and I need the macro to copy and paste all 5 columns down, and also it is inserting the number of rows in column D which is great but I need it to subtract one row from column D value. Example of spreadsheet is customer order# item quantity date price steve 100001 pepsi 3 06/03/04 10.00 jack 100002 coke 8 06/01/04 25.00 To insert rows and copy down Sub insertXrows_copydn() On Error Resume Next For i = 16 To 2 Step -1 x = Cells(i, "d") Y = Cells(i, "a") Cells(i, "a").Resize(x, 1).EntireRow.Insert Cells(i, "a").Resize(x, 1).Value = Y Next i End Sub thanks a bunch . |
Thread Tools | |
Display Modes | |
|
|