View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Macro for duplicating rows based on cell value?

Sorry, I missed the part about the Volume criteria. Use this.

Sub ExpandRows()
lastRw = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastRw To 2 Step -1
counter = 1
Do Until counter = Cells(i, 4).Value
Range(Cells(i, 1), Cells(i, 4)).Copy
Cells(i + counter, 1).Insert
counter = counter + 1
Loop
Next
Application.CutCopyMode = False
End Sub



"Matt.Russett" wrote:

Hello,

Below is a sample of a 200 row file I am working with.

LaneID O Zip D Zip Volume
1 44805 24210 18
2 44805 44309 12

What I need to do is duplicate the rows based on the volume for that
lane, so I can load it into an analysis tool we use.

The manual process I am currently using is to insert 17 rows after
Lane ID 1 and fill down the information so I have a total of 18 rows
for that lane. Doing that for over 200 rows is quite tedious! Does
anyone have any suggestions as to how I could set up a macro or
something so it would automatically look at the Volume column, insert
that many rows, and fill the data down?

Any suggestions are greatly appreciated!

Thanks.