View Single Post
  #5   Report Post  
Mike C
 
Posts: n/a
Default

Dave Peterson wrote:
David McRitchie has some code you can steal.

He even shows how to copy the formulas, but clear out the constants.

http://www.mvps.org/dmcritchie/excel/insrtrow.htm
look for: #insrtrow



none wrote:

Please help with my lame attempt to have the user enter how many times a
row needs to be repeated. Here's the scenario: I have a
spreadsheet with weeks of the year for each year and need each one
repeated a certain number of times.

Sub SOCal()
'
' SOCal Macro

Range("G2").Select
StartVal = Val(InputBox("Enter how many lines per order: "))
Set currentCell = Worksheets("Sheet1").Range("G2")
Do While Not IsEmpty(currentCell)
For counter = 1 To (StartVal - 1)
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1, 0).EntireRow.Insert
ActiveCell.EntireRow.Paste
ActiveCell.Offset(1, 0).Select
Next counter
Loop

End Sub

Thanks for any help.

Mike



Thanks for the help Dave!

I have a problem with my loop. It only copies the first row & pastes it
the correct number of times, but I need it to do the same for all the
rows in the spreadsheet.

Range("G2").Select
StartVal = Val(InputBox("Enter how many lines per order: "))
Do While Not IsEmpty(ActiveCell.Value)
For counter = 1 To (StartVal - 1)
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1).EntireRow.Insert
ActiveCell.Offset(1).EntireRow.PasteSpecial
Next counter
Loop
End Sub

Thanks,
Mike