+ Reply to Thread
Results 1 to 5 of 5

Macro or Formula to create new rows where there is multiple values attached to it

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    36

    Macro or Formula to create new rows where there is multiple values attached to it

    Okay so my title is very hard to explain it so shortly so hopefully this will make sense...

    Basically i will have a sheet with Column A being a unique value (my example is a fruit)
    Column B will include all the values that relate to the unique value and they are ALWAYS separated by a space.

    I need to make multiple rows of the unique value (the fruit) and have each row for that fruit display just one of the values relating to it. So in my example, Banana relates to "8" "7" "6" and "5" so instead of one row that says "banana - 8 7 6 5" I need 4 rows
    Banana - 8
    Banana - 7
    Banana - 6
    Banana - 5

    Hopefully that makes sense :P

    Attached is my example spreadsheet - Sheet 1 being the data i start with and sheet 2 being what i want the result to be. I absolutely cannot do this manually as my real data can be hundreds of rows with hundreds of values attached to each so it takes hours upon hours to do manually

    Thank you

    Example Sheet.xlsx

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Macro or Formula to create new rows where there is multiple values attached to it

    Try running this on the data sheet. A new one will be added.

    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  3. #3
    Registered User
    Join Date
    08-21-2013
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: Macro or Formula to create new rows where there is multiple values attached to it

    Awesome!! thank you, that's perfect. Just tried it on some of my actual data (1350 lines lol) and it worked wonderfully.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Macro or Formula to create new rows where there is multiple values attached to it

    Hi aimee,

    See if this code gets close to what you want. Run the macro on your first page and then delete Columns A and B and maybe Row 1 also.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Macro or Formula to create new rows where there is multiple values attached to it

    For a formula solution.

    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    Apple 1 2 3 4 5 6 7 8 Apple Banana Orange Grape Helper row D1:G1{=TRANSPOSE($A$1:$A$4)}
    2
    Banana 8 7 6 5 1 2 3 4 5 6 7 8 8 7 6 5 8 9 6 5 2 4 1 6 8 7 4 2 6 9 Helper row D2:G2{=TRANSPOSE($B$1:$B$4)}
    3
    Orange 8 9 6 5 2 4 Apple - 1 Banana - 8 Orange - 8 Grape - 1
    4
    Grape 1 6 8 7 4 2 6 9 Apple - 2 Banana - 7 Orange - 9 Grape - 6
    5
    Apple - 3 Banana - 6 Orange - 6 Grape - 8
    6
    Apple - 4 Banana - 5 Orange - 5 Grape - 7
    7
    Apple - 5 Orange - 2 Grape - 4
    8
    Apple - 6 Orange - 4 Grape - 2
    9
    Apple - 7 Grape - 6
    10
    Apple - 8 Grape - 9


    D1:G1 committed all at once by pressing and holding Ctrl and Shift while hitting enter this formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and in D2:G2 this array formula committed the same way.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    These are helper rows.

    Then in D3 array enter also this formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    fill down and across until you get blanks.

    File attached.
    Attached Files Attached Files

+ 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] Create Duplicate Rows for multiple values in a Column.
    By mac2982 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-10-2017, 07:08 PM
  2. Replies: 0
    Last Post: 06-24-2014, 05:51 PM
  3. Help to create list based on multiple criteria (example attached)
    By kfryar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-13-2014, 08:32 PM
  4. [SOLVED] Need help with Formula to change multiple cell's values - Example Attached
    By rufus40444 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-20-2013, 04:52 PM
  5. Replies: 2
    Last Post: 09-29-2010, 03:28 PM

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