+ Reply to Thread
Results 1 to 6 of 6

macro to copy rows based on number in column

Hybrid View

  1. #1
    Registered User
    Join Date
    04-02-2012
    Location
    Sidney, BC
    MS-Off Ver
    Excel 2010
    Posts
    43

    macro to copy rows based on number in column

    Hi,
    I am new to the forum and a stranger to Visual Basic. I have a worksheet in Excel 2010 that has rows like this:

    PLANT TYPE COLOUR PRICE NUMBER
    Achillea kamtschatica gr cover pink $2.00 1
    Agastache perennial blue $1.00 3
    Ajuga gr cover blue $1.00 2

    I have to print labels for a charity plant sale with the name of the plant, type, colour, and price on each label. The number of labels for each plant is given in the NUMBER column. I would like to have a macro that will copy each row just the number of times that is specified in the NUMBER column, so that after the macro runs, the worksheet will look like this:

    PLANT TYPE COLOUR PRICE NUMBER
    Achillea kamtschatica gr cover pink $2.00 1
    Agastache perennial blue $1.00 3
    Agastache perennial blue $1.00 3
    Agastache perennial blue $1.00 3
    Ajuga gr cover blue $1.00 2
    Ajuga gr cover blue $1.00 2

    I would be enormously grateful if someone would send me a macro script that I could paste into Excel's macro editor.
    Thanks in advance!
    Arthur

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: macro to copy rows based on number in column

    Hi
    Can u provide the sample data in a better format?
    Cannot differentiate between PLANT and TYPE...

  3. #3
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: macro to copy rows based on number in column

    Hi
    Try this macro. I hope this solves ur prob:
    DATAREPEATATION.xlsm


    Regards...

  4. #4
    Registered User
    Join Date
    04-02-2012
    Location
    Sidney, BC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: macro to copy rows based on number in column

    Dear jraj1106,

    Thank you for the macro. It worked perfectly. Some day I would like to take a course in VB so that I could understand why it worked! But I so rarely need to use a macro that I shall probably rely on generous people like you to provide me with what I need.

    I am sorry for the poor formatting. When I posted the message all the extra spaces that I inserted in the composition window disappeared. I will know better next time.

    I see that your location is Mauritius. I hope you are enjoying a pleasantly sunny day.

    Arthur

  5. #5
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: macro to copy rows based on number in column

    Hi
    Thanks for your feedback. Pls click on the star below your post.
    Sure, any probs in future I can help you out.
    Thanks again...

    Regards..

  6. #6
    Registered User
    Join Date
    04-03-2012
    Location
    Pakistan
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: macro to copy rows based on number in column

    If any friend can help me in my following thread.

    Automatic Check box insert against each filled row

+ 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