+ Reply to Thread
Results 1 to 13 of 13

Delete Duplicates and Concatenate Unique Cells

  1. #1
    Registered User
    Join Date
    12-16-2010
    Location
    Phnom Penh
    MS-Off Ver
    Excel 2010
    Posts
    7

    Question Delete Duplicates and Concatenate Unique Cells

    Hello,
    This is my first post here - I have been searching around for quite a while for a solution, and I have found posts that are close, but because I don't know VB I am unable to modify them to work for my exact needs.

    What I need is like this: http://www.excelforum.com/excel-prog...nd-delete.html
    and
    http://www.excelforum.com/excel-work...en-delete.html

    Here's my data (I also attached a worksheet):
    What I HAVE:
    Term POS1 POS2 POS3 POS4 POS5 POS6
    find NUM
    fun ROY NNP
    hello NN VB
    hello NN JJ
    try JJ
    try NN


    WHAT I WANT:
    Term POS1
    find NUM
    fun ROY NNP
    hello NN VB JJ
    try JJ NN



    The data is words with their part of speech labels, so I only want one entry per word, but need to concatenate the unique part of speech labels with each word.

    I hope that makes sense - I would appreciate your help!

    Thank you ,
    Nathan
    Attached Files Attached Files
    Last edited by sungkhum; 12-16-2010 at 06:46 AM. Reason: undo

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Delete Duplicates and Concatenate Unique Cells

    Select a cell in the table. From the Data tab select "Remove Duplicates" for Column A

    Not sure what you mean by the rest
    Last edited by royUK; 12-16-2010 at 05:23 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    12-16-2010
    Location
    Phnom Penh
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Delete Duplicates and Concatenate Unique Cells

    Yes, it is a little more complex than that.
    What I have is two identical terms with extra columns that have unique data that I want to concatenate.



    For example:
    hello JJ VB
    hello NN ROY VB

    Would become:
    hello JJ VB NN ROY

    Is that a little clearer?
    Last edited by sungkhum; 12-16-2010 at 06:46 AM. Reason: undo

  4. #4
    Registered User
    Join Date
    12-16-2010
    Location
    Phnom Penh
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Delete Duplicates and Concatenate Unique Cells

    I found code that comes close to what I need for two columns, but I am not sure how to modify it for say, 5 or 6 columns (or however many I need) as well as remove duplicates. Can someone help?

    Please Login or Register  to view this content.
    Last edited by sungkhum; 12-16-2010 at 07:06 AM. Reason: updated info about code

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Delete Duplicates and Concatenate Unique Cells

    Here is another approach. Puts results in K1.
    Please Login or Register  to view this content.
    EDIT: amended slightly, ignore my previous comment about 100 limit, completely wrong!
    Last edited by StephenR; 12-16-2010 at 10:06 AM.

  6. #6
    Registered User
    Join Date
    12-16-2010
    Location
    Phnom Penh
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Delete Duplicates and Concatenate Unique Cells

    Sweet - that seems to do the trick! Thanks! You saved me a ton of time!

    -nathan

  7. #7
    Registered User
    Join Date
    12-16-2010
    Location
    Phnom Penh
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Delete Duplicates and Concatenate Unique Cells

    Actually doing some more testing, there seems to be a problem with duplicates (it almost works every time). Here is a situation where duplicates are allowed:
    test VB NN NN JJ
    test VB

    The result is:
    test VB NN NN JJ

    Is there a way you can remove the duplicates (so there is only one NN for instance).

    Thanks so much!
    -Nathan

  8. #8
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Delete Duplicates and Concatenate Unique Cells

    I think this is better code:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    12-16-2010
    Location
    Phnom Penh
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Delete Duplicates and Concatenate Unique Cells

    Thanks, that seems to do it!

    Would it be possible to put the results in separate columns like before though? That will make it easier when I import more to the data set later.

    Thanks so much - this has been a huge help (I have a list of about 40,000 terms I was going through - and this did it in like a second!).
    -nathan

  10. #10
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Delete Duplicates and Concatenate Unique Cells

    Oops, slipped off the radar. Dictionary is a very powerful tool.
    Please Login or Register  to view this content.
    Do you hang out at the FCC in PP?

  11. #11
    Registered User
    Join Date
    12-16-2010
    Location
    Phnom Penh
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Delete Duplicates and Concatenate Unique Cells

    Awesome - thanks!

    Yes, I do go to FCC occasionally It's a nice spot to hang out. Have you been to Cambodia?
    Actually, the reason I was asking for this macro is because I am working on a grammar checker for Khmer and I am merging part of speech data from a lot of different sources.

    Thanks again,
    Nathan

  12. #12
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Delete Duplicates and Concatenate Unique Cells

    My pleasure.

    Yes visited a friend teaching English there a couple of times, getting on for 10 years ago now so no doubt the city has changed a lot. Very interesting place.

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Delete Duplicates and Concatenate Unique Cells

    Maybe this gives the same result:

    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)

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