+ Reply to Thread
Results 1 to 6 of 6

Listing unique terms from combined strings

  1. #1
    Registered User
    Join Date
    07-24-2012
    Location
    Baltimore
    MS-Off Ver
    Excel for Mac 2011
    Posts
    45

    Listing unique terms from combined strings

    Hi,
    I have string data in a column that I would like to create a list of just the unique terms. Each unique term string in the cell is separated by / . See below for a partial list. Each of these strings is entirely in one cell. I do not need the number of times or in what combinations the terms appear. Just a list of each unique term. For example, C DIFF occurs multiple times. I want a list where it occurs only once. And so on for each unique term. Any ideas?
    Thanks!

    GASTRIC LYMPHOMA
    ESOPHAGEAL CANDIDIASIS
    C DIFF/PANCREATITIS
    **** CONDYLOMA/PERIANAL FISTULA
    GERD/C DIFF/GASTRITIS/DUODINITIS/ESOPH
    GERD/SMALL BOWEL RESECTION/APPENDECTOMY/CHRONIC ABD PAIN
    PERIRECTAL ABSCESS/HSV
    DIAHHREA
    DIAHHREA/C DIFF/GERD H PYLORI/HIATAL HERNIA/ESOPH SPASM
    PERIANAL HSV
    C DIFF
    ORAL CANDIDIASIS
    GERD
    ESOPHAGEAL CANDIDIASIS/C DIFF

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

    Re: Listing unique terms from combined strings

    This isn't a formula question, it's a VBA question. you would need a macro to parse out each string by the / delimiter and add it to a list if it's new. Here's a simple macro that can do this.... it assumes the data is in column A, it will create a new list for you in column D.

    Please Login or Register  to view this content.
    How/Where to install the macro:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save as a macro-enabled workbook

    The macro is installed and ready to use. Press Alt-F8 and select it from the macro list.
    _________________
    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!)

  3. #3
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,883

    Re: Listing unique terms from combined strings

    Nice macro! I used a manual approach that worked ok.
    The text to columns feature got rid of the /. Then I added a column to the far right with COUNTA(A1:F1) or whatever range, hence I could get it sorted by no of strings. When that was done it was a few, easy, copy pastes to get it in one column. Then added a column with just ones just to the right, applied the Consolidate feature and got the result.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  4. #4
    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: Listing unique terms from combined strings

    Hi,

    The following macro is one way. Just make sure the list is in column A. The macro will add a new sheet and put the unique values in C1

    Please Login or Register  to view this content.
    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.

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

    Re: Listing unique terms from combined strings

    If that takes care of your original query, please select Thread Tools from the menu above and mark the thread as solved. Thanks.

  6. #6
    Registered User
    Join Date
    07-24-2012
    Location
    Baltimore
    MS-Off Ver
    Excel for Mac 2011
    Posts
    45

    Re: Listing unique terms from combined strings

    The first macro worked great. Thanks so much!

+ 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