+ Reply to Thread
Results 1 to 16 of 16

How To Duplicate Cells based on a specific quantity

  1. #1
    Registered User
    Join Date
    07-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    7

    How To Duplicate Cells based on a specific quantity

    Hi,


    I have many, many rows of data and need to duplicate it on rows a specific number of times. In the example below, I need "fishing boat" and "florida" copied 50 times to rows below. I need "lure" and "florida" copied 100 times. Is there a way to do this easily without having to manually copy/past?

    Thanks,
    Mike

    excel question.png

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How To Duplicate Cells based on a specific quantity

    That is easily done.

    right click on the row you want to copy and select copy.

    left click on the row no on the left of excel of where you want to copy your row and drag down

    Now right click and select "Insert Copied Cells"

  3. #3
    Registered User
    Join Date
    07-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: How To Duplicate Cells based on a specific quantity

    Thanks, mehmetcik. I already know how to do that.

    I'm looking for a way to MASS copy/paste all data at one time. I have hundreds of rows of data, so copying each one individually is too slow.

    Any other ideas?

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How To Duplicate Cells based on a specific quantity

    LOL

    That wasn't clearly stated.

    So how do I know which row you want duplicated and how many times?

    Are you placing a number in column A for example?

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How To Duplicate Cells based on a specific quantity

    Ahh I don't normally look at image files.

    Your number is in column C

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How To Duplicate Cells based on a specific quantity

    Mike,
    Next time, you need to post a sample book, not a picture. Try the attached.
    The code copies the new data in column D and E

  7. #7
    Registered User
    Join Date
    07-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: How To Duplicate Cells based on a specific quantity

    I'm sorry. I see the download you sent with the cells copied, but what is the actual formula that copied them? That's all I need

    I'm also not sure how to post a "sample book".

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How To Duplicate Cells based on a specific quantity

    try this code

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mehmetcik; 11-26-2013 at 08:22 PM.

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How To Duplicate Cells based on a specific quantity

    However I think that you are on the wrong track

    Solution2 is probably what you really need.

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

  10. #10
    Registered User
    Join Date
    07-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: How To Duplicate Cells based on a specific quantity

    Oh sorry, i see the code now. So i have no idea what to do with this?

    I only know formulas. Can you help?

  11. #11
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How To Duplicate Cells based on a specific quantity

    Wow

    no-one answered for me.


    Did you run the macros?

    To run them

    Click on developer on your excel tool bar then macros

    two macros will be listed solution1 and solution2

    run one, quit the file and run the other.

    To see and edit the code

    Click on developer

    select a macro and click on edit

  12. #12
    Registered User
    Join Date
    07-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: How To Duplicate Cells based on a specific quantity

    Hey, I'm sorry, but I have no idea what you're talking about. I don't see 'developer'.

    Isn't there just a formula I can use to do this?

  13. #13
    Registered User
    Join Date
    07-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: How To Duplicate Cells based on a specific quantity

    Ok, I'm learning. I found this macro on another forum at http://en.kioskea.net/faq/7546-excel...f-times#goprev

    Sub CopyData()
    Dim lRow As Long
    Dim RepeatFactor As Variant

    lRow = 1
    Do While (Cells(lRow, "A") <> "")

    RepeatFactor = Cells(lRow, "B")
    If ((RepeatFactor > 1) And IsNumeric(RepeatFactor)) Then

    Range(Cells(lRow, "A"), Cells(lRow, "B")).Copy
    Range(Cells(lRow + 1, "A"), Cells(lRow + RepeatFactor - 1, "B")).Select
    Selection.Insert Shift:=xlDown

    lRow = lRow + RepeatFactor - 1
    End If

    lRow = lRow + 1
    Loop
    End Sub

    It works perfectly for the case given. How would you modify the macro above so that it copies data in columns A and B, based on the value in column C?

    Thanks for hanging in there with me.
    Mike

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How To Duplicate Cells based on a specific quantity

    If you bother to use VBA, why do you need to use another code while my code works.

  15. #15
    Registered User
    Join Date
    07-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: How To Duplicate Cells based on a specific quantity

    I got it working now. Thanks.

    Can anyone tell me how to save the VBA macro to my spreadsheet?

    Also, if I run the macro by mistake, is there a way to UNDO it?

    Thanks
    Mike

  16. #16
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How To Duplicate Cells based on a specific quantity

    If you mean you want access the code in your personal book, the easiest way would be to:
    Record a macro:
    Follow the steps, but when you click the macro recorder, a screen will pop up. The first box is naming the code.

    You then have (2 below) "store the macro" option, thisworkbook is the default option, you need to choice this personal workbook.
    This means you have created a book for all you macros,so when ever you open an excel book, the personal workbook is uploaded.
    The next step is to drag, or copy the code in to personal workbook so that when ever you open a book, the code will appear.

    UNDO a code is too complicate for you, so I suggest you should be first comfortable running and editing codes.
    To avoid unnecessary headache, you should save your workbook before you run any code.
    Last edited by AB33; 11-29-2013 at 03:24 PM.

+ 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. Remove Duplicate Rows based on Specific Values
    By zeanzi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-31-2013, 08:01 PM
  2. Replies: 1
    Last Post: 08-15-2013, 04:12 PM
  3. [SOLVED] Macro for Deleting Multiple Rows Based of 2 Cells and Update Quantity
    By michaelpair in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-05-2013, 11:02 AM
  4. Replies: 0
    Last Post: 12-28-2012, 06:24 PM
  5. Replies: 5
    Last Post: 11-23-2009, 06:24 PM

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