+ Reply to Thread
Results 1 to 10 of 10

Creating a comma separated list for unique entires

  1. #1
    Registered User
    Join Date
    07-19-2012
    Location
    Philadelphia,PA
    MS-Off Ver
    Excel 2007
    Posts
    20

    Creating a comma separated list for unique entires

    Please let me know how I can achieve the following:

    I have this:

    NAME STATE
    BOB PA
    BOB NJ
    BOB DE
    TOM PA
    TOM DE

    I need to have this:

    NAME STATE
    BOB PA, NJ, DE
    TOM PA, DE

    I have to do this on a very large scale and doing it manually is just not an option... any ideas would be greatly appreciated.

    Thanks!
    Last edited by JBeaucaire; 07-22-2012 at 09:35 PM. Reason: Corrected thread title to topic only, as per forum rules

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Please help! Trouble creating a comma separated list for unique entires

    Hi,

    Assuming the original table is in A1:Bnn, and is sorted on the name then use a couple of helper columns.

    C2:
    =IF(A2=A1,C1&","&B2,B2)

    D2:
    =COUNTIF($A2:$A$6,A2)
    change the row 6 to suit

    Copy C2:D2 down, filter the list on column D for the value 1. Then copy the filtered rows and copy them wherever.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Please help! Trouble creating a comma separated list for unique entires

    Time for VBA

    Insert this VBA oode,

    Please Login or Register  to view this content.
    Then extract unique Name by Advanced Filter & enter them D2 to down. In E2,

    =CONCATIF(A:A,D2,B:B,", ",1)

    A:A = Name, B:B = State, 1 for exclude duplicate
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  4. #4
    Registered User
    Join Date
    07-19-2012
    Location
    Philadelphia,PA
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Please help! Trouble creating a comma separated list for unique entires

    This is so helpful! Thank you.

    Another minor issue.. in some cases, all 50 states will be listed..I dont want to have to spread the cell out to view everything.. this will need to be printed.. is there a way to set it up so that I can put in a hard return after every third value?

    So instead of

    PA, NJ, DE, IL, NY, AZ

    I could get

    PA, NJ, DE, (Alt+Enter)
    IL, NY, AZ

  5. #5
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Please help! Trouble creating a comma separated list for unique entires

    Adjust the column width & use 'Wrap Text'

  6. #6
    Registered User
    Join Date
    07-19-2012
    Location
    Philadelphia,PA
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Please help! Trouble creating a comma separated list for unique entires

    Using wrap text causes some of the state names to get split up like this:

    PA,NJ,D
    E,IL,NY
    ,AZ

  7. #7
    Registered User
    Join Date
    07-19-2012
    Location
    Philadelphia,PA
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Please help! Trouble creating a comma separated list for unique entires

    can Alt-Enter after every third value be automated?

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Please help! Trouble creating a comma separated list for unique entires

    Here you go:
    Please Login or Register  to view this content.

    You will need to still turn on Wrap Text in those cells.
    Last edited by JBeaucaire; 07-23-2012 at 01:57 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  9. #9
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Creating a comma separated list for unique entires

    Maybe try this sub:

    Please Login or Register  to view this content.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,522

    Re: Creating a comma separated list for unique entires

    try
    Please Login or Register  to view this content.

+ 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