+ Reply to Thread
Results 1 to 8 of 8

Create duplicate rows based on value in a column

  1. #1
    Registered User
    Join Date
    02-06-2010
    Location
    San Juan, Puerto Rico
    MS-Off Ver
    Excel 2007
    Posts
    1

    Post Create duplicate rows based on value in a column

    Hello, All. I need a VBA/macro very similar to several I have seen posted here. I have a worksheet with two columns and a few hundred lines. One has titles and the other integers indicating how many times the title needs to be copied to another worksheet or text file.

    Existing Worksheet (Input)
    TitleA 1
    TitleB 6
    TitleC 4
    TitleD 3

    Desired Output (Worksheet or Text File) [The entire row, including the integer could be copied as well, if it is easier.]
    TitleA
    TitleB
    TitleB
    TitleB
    TitleB
    TitleB
    TitleB
    TitleC
    TitleC
    TitleC
    TitleC
    TitleD
    TitleD
    TitleD

    This should be simple, but I am a total newbie with Excel VBA/macros. A sample is attached. Any help will be greatly appreciated.

    [Thanks to both for quick and clear replies.]
    Attached Files Attached Files
    Last edited by PGonzalez; 02-06-2010 at 05:05 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Create duplicate rows based on value in a column

    Like so:

    Please Login or Register  to view this content.
    This will create the listing for you on Sheet2. Make sure Sheet1 is a clean set of data and run the macro. It assumes the data starts at row2.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Create duplicate rows based on value in a column

    here you go

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-24-2012
    Location
    Boulder, CO
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Create duplicate rows based on value in a column

    Perfect! Thanks Mally

  5. #5
    Registered User
    Join Date
    12-04-2012
    Location
    WI
    MS-Off Ver
    Excel 97
    Posts
    1

    Re: Create duplicate rows based on value in a column

    Do you have this on your website?

  6. #6
    Registered User
    Join Date
    01-20-2014
    Location
    Delhi
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Create duplicate rows based on value in a column

    Please help me am not able to run that file....

    how and where multi column created .

    please share how to use that file.......


    Kindly do the needful.

  7. #7
    Registered User
    Join Date
    04-12-2014
    Location
    Lubbock, TX
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Create duplicate rows based on value in a column

    How can you modify this code to copy an entire row a number of times specified in one column, such as the second column in this example? This code works great for copying the first column, but what if I need to copy many columns? Thanks!

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Create duplicate rows based on value in a column

    IamVBADumb,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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