Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Mike C
 
Posts: n/a
Default Please help with loop

I need all the rows which contain data to repeat a certain number of
times. My attempt works perfectly for the first row, but stops there.

Sub Try()

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 for any help.
Mike
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

You have another reply at your other thread.

Mike C wrote:

I need all the rows which contain data to repeat a certain number of
times. My attempt works perfectly for the first row, but stops there.

Sub Try()

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 for any help.
Mike


--

Dave Peterson
  #3   Report Post  
Chip Pearson
 
Posts: n/a
Default

Mike,

You'll need to Select the next cell.
...
ActiveCell.Offset(1,0).Select
Next Counter



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Mike C" wrote in message
...
I need all the rows which contain data to repeat a certain
number of times. My attempt works perfectly for the first row,
but stops there.

Sub Try()

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 for any help.
Mike



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping Macro to Find and Mark Big Tony New Users to Excel 8 January 26th 05 09:07 PM
macro loop Helen Excel Discussion (Misc queries) 7 January 12th 05 02:42 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM
How to incorporate Loop feature Jim May Excel Discussion (Misc queries) 4 December 16th 04 11:41 PM
VBA Newbie: Help with Do Loop code Carl Excel Discussion (Misc queries) 3 December 2nd 04 07:04 PM


All times are GMT +1. The time now is 06:52 AM.

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

About Us

"It's about Microsoft Excel"