+ Reply to Thread
Results 1 to 7 of 7

Need Macro to Duplicate Rows based on input

  1. #1
    Registered User
    Join Date
    02-13-2013
    Location
    san diego, ca
    MS-Off Ver
    Excel 2001 for Mac
    Posts
    8

    Need Macro to Duplicate Rows based on input

    Hi Geniuses of Excel Forum! I have quite the project I could use your help with. At current, I have a spreadsheet with a list of 8,000 store addresses. What I need to do is duplicate each addresses 2 times to have a total of 3 of each address. Any way to write a macro for this? Example below:

    Currently have:

    • Store A
    • Store B
    • Store C



    Need to have:

    • Store A.1
    • Store A.2
    • Store A.3
    • Store B.1
    • Store B.2
    • Store B.3
    • Store C.1
    • Store C.2
    • Store C.3

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: Need Macro to Duplicate Rows based on input

    Hi there,

    See if the following code does what you need:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your own requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need Macro to Duplicate Rows based on input

    FWIW:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-13-2013
    Location
    san diego, ca
    MS-Off Ver
    Excel 2001 for Mac
    Posts
    8

    Re: Need Macro to Duplicate Rows based on input

    Thank you for replying to my question. Although the code provided did accomplish what I asked for, I wasn't completely clear on what the objective was. Here is the real life version of what is needed if you wouldnt mind helping again.

    I work for a protein bar company and we sell two flavors in all 7-elevens convenience stores around the US. I need to upload a spreadsheet to my retail locator that has each location listed twice: once with flavor a, once with flavor b.

    At present i only have a list of 6,000+ 7-eleven stores with one row for each store. The objective is to duplicate each row so that the list becomes 12,000 rows with each store listed twice. Rather than manually copying and pasting I was curious if a macro could take care of this.


    Current List
    7-Eleven 30 N. SUMMERLIN AVE Orlando FL 32801 (407)423-2912
    7-Eleven 2609 S DELANEY AVE Orlando FL 32806 (407)423-3570
    7-Eleven 1500 EDGEWATER DR Orlando FL 32804 (407)841-0658
    7-Eleven 723 NORTH MILLS AVE Orlando FL 32803 (407)894-0887

    What the outputted list should look like
    7-Eleven 30 N. SUMMERLIN AVE Orlando FL 32801 (407)423-2912
    7-Eleven 30 N. SUMMERLIN AVE Orlando FL 32801 (407)423-2912
    7-Eleven 2609 S DELANEY AVE Orlando FL 32806 (407)423-3570
    7-Eleven 2609 S DELANEY AVE Orlando FL 32806 (407)423-3570
    7-Eleven 1500 EDGEWATER DR Orlando FL 32804 (407)841-0658
    7-Eleven 1500 EDGEWATER DR Orlando FL 32804 (407)841-0658
    7-Eleven 723 NORTH MILLS AVE Orlando FL 32803 (407)894-0887
    7-Eleven 723 NORTH MILLS AVE Orlando FL 32803 (407)894-0887

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need Macro to Duplicate Rows based on input

    Does this help?

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-13-2013
    Location
    san diego, ca
    MS-Off Ver
    Excel 2001 for Mac
    Posts
    8

    Re: Need Macro to Duplicate Rows based on input

    this is 99% there. It does not copy the first row of stores. More speficically:

    Starting List

    Store A
    Store B
    Store C

    After running macro

    Store A
    Store B
    Store B
    Store C
    Store C

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need Macro to Duplicate Rows based on input

    Is the first store on row 1? I assume there was a header.

+ 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. Macro to duplicate rows based on cell value
    By KBEZ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2016, 11:58 AM
  2. Macro to create duplicate rows based on the value of particular fields
    By EmicoCP in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2015, 09:33 AM
  3. Macro to duplicate rows based on value in A column
    By gemmasou81 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-26-2014, 06:22 AM
  4. Generating Macro to create multiple duplicate cells based on an input reference
    By Jomian in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2013, 08:25 PM
  5. Macro to hide rows based on values of input cells
    By kalts2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2013, 09:28 AM
  6. Macro to Copy Rows based on User Input
    By CharterJP in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-24-2012, 06:13 PM
  7. Macro to Filter Copy the rows based on input
    By souvick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2011, 02:47 AM

Tags for this Thread

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