creating new cells based on cell value in separate sheet

licorice1969

New Member
Joined
Aug 28, 2019
Messages
2
Good morning ... I'm not sure if this can be done, or even how exactly to describe it, but here goes ...

I need to create a "ballot" file, which I will then refer to after generating a random number using a formula.

I have a source spreadsheet with names and the # of ballots each name gets, what I don't know how to do is to generate a separate worksheet or workbook, which will then put each name in a cell in column A the appropriate number of times.

For example, if the source workbook is:

AB
1John2
2Jane5
3Steve3

<tbody>
</tbody>







... the new worksheet/workbook would look like this:

A
1John
2John
3Jane
4Jane
5Jane
6Jane
7Jane
8Steve
9Steve
10Steve

<tbody>
</tbody>

















Does anyone know how to accomplish this, or even point me in the right direction?

Much thanks in advance for any assistance!

PS - Not sure why there are so many blank lines after the 2nd table, when I edit the post there are none. :confused:
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,992
Office Version
365
Platform
Windows
Hi & welcome to MrExcel.
How about
Code:
Sub licorice1969()
   Dim Cl As Range
   Dim Ws As Worksheet
   
   Set Ws = Sheets.Add
   With Sheets("[COLOR=#ff0000]Master[/COLOR]")
      For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         Cl.Copy Ws.Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(1 * Cl.Offset(, 1).Value)
      Next Cl
   End With
End Sub
Change sheet name to suit
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,992
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Forum statistics

Threads
1,081,556
Messages
5,359,547
Members
400,533
Latest member
fpenning

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top