Inserting Records Based on Cell Value

gcot

New Member
Joined
Feb 4, 2004
Messages
28
Hi All,

Anybody know of a quick way to duplicate records based on a cell value.

I have a list of people for which I've determined are eligible for x amount of ballots each for a prize draw. What I need is a way to duplicate every name based on the number of ballots. For example.

Source data:

Participant Ballots
John 6
Paul 4
Ralph 3

The results should be:

John
John
John
John
John
John
Paul
Paul
Paul
Paul
Ralph
Ralph
Ralph

Any help would be appreciated.

Thanks,

Gilles
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If you are looking for code something like this perhaps?
Code:
Sub InsertCopy()
Dim rng As Range
Dim NoRows
    Set rng = Range("A1")
    
    While rng.Value <> ""
        NoRows = rng.Offset(, 1) - 1
        rng.Offset(1).Resize(NoRows).EntireRow.Insert
        rng.Offset(1).Resize(NoRows) = rng.Value
        Set rng = rng.Offset(NoRows + 1)
    Wend
End Sub
 
Upvote 0
I think that will work.

Thanks Norie. Tried it and it seemed to have worked. I just need to do some validation but looks good at first glance. That was a great help!!

Thanks very much.

Gilles
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top