macro to add rows and copy data into the rows

  • Thread starter Thread starter Steve
  • Start date Start date
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
 
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
 
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
 
Back
Top