+ Reply to Thread
Results 1 to 7 of 7

Duplicate Row based on a value in that row.

  1. #1
    Registered User
    Join Date
    02-13-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Duplicate Row based on a value in that row.

    Afternoon all. A friend asked me to help with her spreadsheet but this ones got me stumped.
    The sheet is a list of names in column A, in column B is the number of raffle tickets they have.What im trying to do via VBA is look at the first name in the column and duplicate that entry to the next lines depending on how many tickets that person has. Then go to the next name and continue until there are no further entries.

    The first rows in the attachment shows the 'Raw' data. Row 8 onwards shows what im wanting it to look like when finished. I did find some code during a search that could look at the date and then insert that many rows; but not copy the data to each row.

    Eventually each entry will be numbered from 1 to (Total tickets) and then a random number generator used.

    Many thanks for any help available
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    10-24-2014
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    6

    Re: Duplicate Row based on a value in that row.

    Probably not the most elegant solution, but this might work. It takes everything in cols A:B and breaks it out into E:F

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Duplicate Row based on a value in that row.

    Another option:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-13-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Duplicate Row based on a value in that row.

    Hi stnkynts. That second option works great. Thank you very much, especially for such a quick response.

    Is there a way i can modify that code so that data in additional columns is also copied down. For instance on my original document i also have data in columns C to H, which includes office and department relating to the name in column A.
    When this code runs it doesn't copy the whole row, just A:B. Which is my fault as that was the only info i gave you in the example; sorry about that.

    Thanks again

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Duplicate Row based on a value in that row.

    This line is what is doing the "copying".

    Please Login or Register  to view this content.
    If you wish to specify the columns you can do so by changing the "2" that resides within the Resize. The number 2 means column A & B. 3 would be A & B & C. 4 would be A,B,C,D, etc. Or you could just do then entirerow like this

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-13-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Duplicate Row based on a value in that row.

    Your a star. Works a treat.

    Thank you

  7. #7
    Registered User
    Join Date
    02-13-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Duplicate Row based on a value in that row.

    Your a star. Works a treat.

    Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Sort row based on duplicate value
    By nobodyNZ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2014, 12:33 PM
  2. [SOLVED] Delete rows based on duplicate cell, but leaving first and last duplicate.
    By LadyNicole in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-28-2013, 05:07 AM
  3. Duplicate row based on a cell value
    By pr0metheus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-25-2012, 03:30 PM
  4. Duplicate rows based on condition
    By booo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-08-2010, 06:34 AM
  5. Return a value based on duplicate names
    By Jimmy H in forum Excel General
    Replies: 2
    Last Post: 07-14-2005, 02:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1