+ Reply to Thread
Results 1 to 10 of 10

Merge values from column in one cell, based on duplicates in another column

  1. #1
    Registered User
    Join Date
    01-15-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    10

    Merge values from column in one cell, based on duplicates in another column

    Hi!

    I know, the title is very hard to undestand. What I'd like to do is turn this:

    A B
    London Blue
    London Green
    New York Yellow
    New York White
    New York Blue
    Milano Blue

    Into this:

    A B
    London Blue, Green
    New York Yellow, White, Blue
    Milano Blue

    Or this:

    A B C D
    London Blue Green
    New York Yellow White Blue
    Milano Blue

    As you can see, values in column A should only occure once. For all rows that each value occured, the values in column B should somehow be merged in the same row. Just look at the tables if my explanation doesn't make sense

    Can I do this with a formula or do I need a VBA script? Obviously there are lots of more rows and columns in the real worksheet.

    Thanks!
    Last edited by Rawland_Hustle; 01-15-2014 at 08:50 AM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Merge values from column in one cell, based on duplicates in another column

    Assume that your data is from A1:B6

    In D2 cell - Array Formula - Requires CTRL+SHIFT+ENTER

    =IFERROR(INDEX($A$1:$A$6,MATCH(0,COUNTIF($D$1:$D1,$A$1:$A$6),0)),"")

    Drag it down...

    In E2 cell - Array Formula - Requires CTRL+SHIFT+ENTER

    =IFERROR(INDEX($B$1:$B$6,SMALL(IF($A$1:$A$6=$D2,ROW($A$1:$A$6)-MIN(ROW($A$1:$A$6))+1),COLUMN(A:A))),"")

    Drag it down and right....

    Array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    01-15-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Merge values from column in one cell, based on duplicates in another column

    Thanks for the quick reply!

    I should of course have mentioned this in my initial post: in my worksheet, all the columns have duplicates but the formula should only be used for column C and G. It actually looks like this (I've left the other columns blank here but they do have values):

    A B C D E F G
    London Blue
    London Green
    New York Yellow
    New York White
    New York Blue
    Milano Blue

    I'm going to apply this formula on many worksheets so I'd like to understand which values in the formula that I should change, depending on how many rows the particular worksheet has. The columns are always the same, the data starts in A2 and ends in G-something

  4. #4
    Registered User
    Join Date
    01-15-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Merge values from column in one cell, based on duplicates in another column

    To clarify: There are values in the other columns which are the same for every duplicate in column C. Those values should be should be kept on one row.

    Is this possible?

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Merge values from column in one cell, based on duplicates in another column

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  6. #6
    Registered User
    Join Date
    01-15-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Merge values from column in one cell, based on duplicates in another column

    I have attached a sample workbook. The result in sheet AFTER (1) is the one I'd prefer but AFTER (2) works too

    Se sheet EXPLAINED for explanation of what the formula actually should do. Bare in mind that the actual workbooks contains up to 6000-7000 rows. It varies from workbook to workbook.

    I'd be very happy if someone could solve this! :D
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-15-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Merge values from column in one cell, based on duplicates in another column

    Was it okay?

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

    Re: Merge values from column in one cell, based on duplicates in another column

    Quote Originally Posted by Rawland_Hustle View Post
    Hi!

    I know, the title is very hard to undestand. What I'd like to do is turn this:

    A B
    London Blue
    London Green
    New York Yellow
    New York White
    New York Blue
    Milano Blue

    Into this:

    A B
    London Blue, Green
    New York Yellow, White, Blue
    Milano Blue

    Or this:

    A B C D
    London Blue Green
    New York Yellow White Blue
    Milano Blue

    As you can see, values in column A should only occure once. For all rows that each value occured, the values in column B should somehow be merged in the same row. Just look at the tables if my explanation doesn't make sense

    Can I do this with a formula or do I need a VBA script? Obviously there are lots of more rows and columns in the real worksheet.

    Thanks!
    Maybe:

    Please Login or Register  to view this content.

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

    Re: Merge values from column in one cell, based on duplicates in another column

    Another one!
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    01-15-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Merge values from column in one cell, based on duplicates in another column

    You guys are awesome! It worked fine and I really appreciate your help!

    THANKS!!!

+ 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. Replies: 8
    Last Post: 08-08-2013, 08:45 AM
  2. [SOLVED] Find duplicates in column A, add values from column B (possibly delete duplicates)
    By luarwhite in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-12-2013, 04:34 PM
  3. [SOLVED] Remove rows based on duplicates in certain columns, and merge data from another column
    By yanagi600 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-02-2013, 04:17 PM
  4. Remove duplicates on column A and merge rows in column B
    By JJcool in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-29-2012, 05:41 PM
  5. Replies: 2
    Last Post: 06-02-2010, 01:20 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