+ Reply to Thread
Results 1 to 13 of 13

Delete repeated words in every cells in a Range

  1. #1
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Delete repeated words in every cells in a Range

    Hello!
    I have thousands of cells with repeated terms, and would like to delete the repeated/duplicate words in the cells without deleting the entire rows.

    I found the following VBA code (below) on this forum that comes close to achieving this end but with some limitations that I need help with.
    Here is an example of a cell content: Measles, Measles, Measles, Measles, Measles, Measles, Measles, Dengue, Dengue, Dengue, Dengue, Dengue, Dengue, Dengue

    Running the code gives the following: Measles, , , , , , , Dengue, , , , , ,

    But ideally, I would want to just have Measles, Dengue

    Any help would be much appreciated. Thanks



    Please Login or Register  to view this content.
    Last edited by mmtoure; 06-13-2013 at 08:59 AM. Reason: added code tag

  2. #2
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Pune
    MS-Off Ver
    Office 365 (Win 10)
    Posts
    489

    Re: Delete repeated words in every cells in a Range

    Please use 'wrap' option while inserting any code
    Please make the Post as solved, when you get your answer & Click * if you like my suggestion

  3. #3
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete repeated words in every cells in a Range

    Sorry about that. Here is the code wrapped.
    Please Login or Register  to view this content.
    Last edited by mmtoure; 06-13-2013 at 08:46 AM. Reason: Added code tag

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

    Re: Delete repeated words in every cells in a Range

    Hello and welcome to the forum,

    Please add code tags by highlighting your code and pressing on the pound sign (#) or adding [Code] before your code and [/ Code] after your code (but remove the space between the forward slash and the word Code.

    Once you comply, I can post the updated code.

    Thanks.

    abousetta
    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.

  5. #5
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete repeated words in every cells in a Range

    Hi abousetta,
    I just made the edits. Hope that works. Thanks.

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

    Re: Delete repeated words in every cells in a Range

    Don't forget to do this for post #1 also:

    Here is the updated code. You don't need to use RegScript, only the scripting dictionary:

    Please Login or Register  to view this content.
    Hope this helps.

    abousetta

  7. #7
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete repeated words in every cells in a Range

    Wow, thanks a lot, abousetta!
    It worked like magic.

  8. #8
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete repeated words in every cells in a Range

    Wow, thanks a lot, abousetta!
    It worked like magic.

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

    Re: Delete repeated words in every cells in a Range

    Yes, scripting does wonders. I'll be honest I don't know RegEx but you could probably accomplish the same thing there also.

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

    Re: Delete repeated words in every cells in a Range

    Thanks for marking the thread as solved. Good luck.

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

    Re: Delete repeated words in every cells in a Range

    Maybe:

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete repeated words in every cells in a Range

    Thanks, John for your help as well.

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

    Re: Delete repeated words in every cells in a Range

    Welcome. Glad you got a solution.

+ 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