A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

macro to insert rows and copy and paste



 
 
Thread Tools Display Modes
  #1  
Old June 4th, 2004, 01:58 PM
STEVE
external usenet poster
 
Posts: n/a
Default 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  
Old June 4th, 2004, 06:26 PM
JC
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:35 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.