+ Reply to Thread
Results 1 to 7 of 7

How to remove duplicate values from comma separated values in a cell ?

  1. #1
    Registered User
    Join Date
    09-29-2021
    Location
    USA
    MS-Off Ver
    2019
    Posts
    18

    How to remove duplicate values from comma separated values in a cell ?

    Hi,

    I have a requirement to remove the duplicate string values from a cell in excel.

    Currently, one of the rows has values like - Type 1, Type 1, Type 2. I need to trim that cell value to - Type 1, Type 2

    Here's the macro code behind it -

    Please Login or Register  to view this content.
    I am totally new to VBA coding and would greatly appreciate any help. Thank you in advance.
    Last edited by AliGW; 09-30-2021 at 02:12 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Excel: How to remove duplicate values from comma separated values in a cell ?

    Maybe you can tweak the code below to suite your condition.

    Please Login or Register  to view this content.
    The code assumes that cell A1 value is something like this :
    Type 1, Type 1, Type 2, Type 3, Type 4, Type 1, Type 3

    Then the code put the value to cell A1 like this
    Type 1, Type 2, Type 3, Type 4
    Last edited by karmapala; 09-29-2021 at 11:03 PM.

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

    Re: Excel: How to remove duplicate values from comma separated values in a cell ?

    Quote Originally Posted by Sravya22 View Post
    Currently, one of the rows has values like - Type 1, Type 1, Type 2. I need to trim that cell value to - Type 1, Type 2
    Assuming your code is generating such string...
    1) change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    2) Add the following function to a standard code module or the one in which your code is written.
    Please Login or Register  to view this content.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,171

    Re: Excel: How to remove duplicate values from comma separated values in a cell ?

    Another Option...
    Please Login or Register  to view this content.
    Edit...
    Oops...Just noticed jindon similar code...
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,455

    Re: How to remove duplicate values from comma separated values in a cell ?

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new, I have done it for you today.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    09-29-2021
    Location
    USA
    MS-Off Ver
    2019
    Posts
    18

    Re: How to remove duplicate values from comma separated values in a cell ?

    Thank you for all your responses. It worked Appreciate it very much.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,455

    Re: How to remove duplicate values from comma separated values in a cell ?

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

+ 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. [SOLVED] Remove duplicate values in Field cell from same column
    By nironto in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-22-2016, 01:40 AM
  2. Macro to remove duplicate values from cell
    By Hypex in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2016, 05:34 PM
  3. [HELP] me to remove duplicate values and leave that cell as blank
    By spa3212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-30-2015, 01:23 PM
  4. [HELP] me to remove duplicate values and leave that cell as blank
    By spa3212 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-30-2015, 12:55 AM
  5. Formula or code to remove duplicate text or values within a cell
    By winmaxservices1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-22-2014, 06:16 AM
  6. How to remove duplicate values in Microsoft Excel?
    By happyjack in forum Excel General
    Replies: 3
    Last Post: 12-05-2013, 02:47 PM
  7. [SOLVED] Remove duplicate rows by matching values across columns in Excel 2007
    By guest2013 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-15-2013, 12:00 AM

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