macro to add rows and copy data into the rows

S

Steve

I have a monthly query I run that has my sales for the
month in the following format.

customer ordernumber item quantity date price
steve 1000001 pepsi 5 05/01/04 10.00

This spreadsheet has 1000's of different orders and so on.

I need a macro or something to add 4 more rows for the
above scenerio and copy that row into them. So every
change in order number and quanity and item it would do
this if it was more then a quaniity of one.

Please help it would save me days of work.
Steve
 
J

JC

Steve try this:

Sub Insert_Blank_Rows()

'Select last row in worksheet.
Selection.End(xlDown).Select

Do Until ActiveCell.Row = 1
'Insert blank row.
ActiveCell.EntireRow.Insert shift:=xlDown
ActiveCell.EntireRow.Insert shift:=xlDown
ActiveCell.EntireRow.Insert shift:=xlDown
ActiveCell.EntireRow.Insert shift:=xlDown
ActiveCell.Offset(4, 0).Select
ActiveCell.EntireRow.Select
Selection.Copy
ActiveCell.Offset(-1, 0).Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 0).Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 0).Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 0).Select
ActiveSheet.Paste
'Move up one row.
ActiveCell.Offset(-1, 0).Select
Loop

End Sub
 
S

Steve

Will this solution work if my quanitites are different for
each order, its not always a quantity of 5 that I need
rows for.

Thanks a bunch
Steve
 

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