+ Reply to Thread
Results 1 to 38 of 38

highlight duplicate names within single cell

  1. #1
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    highlight duplicate names within single cell

    Hi,
    I am new to VBA trying highlight duplicates from a single cell,
    I have range D6 to J75, each cell contains names separated by comma and space, and some times repeated for example D6 as Joes, Tony, Samuel, Joes, and E8 as Adrian, Sam, Prakash, Tony, After the macro: It should highlight Joes in D6 & Tony in E8,


    Any help would be much appreciated, many thanks

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: highlight duplicate names within single cell

    Try this:-
    Please Login or Register  to view this content.
    Regards Mick

  3. #3
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    Hi,
    Thank you very much, sorry one more help can I make this work automatic.

    thanks a lot
    regards
    rao

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: highlight duplicate names within single cell

    You're welcome

    Paste the code below into the active sheet code module.
    Code runs when cell altered in range "E6:J75".
    Please Login or Register  to view this content.
    Regards Mick

  5. #5
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    sir,
    thanks a lot,

    regards,
    rao

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: highlight duplicate names within single cell

    You're welcome

  7. #7
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    Hi,
    once again I need your help, I want to find count from the range of cell having values separated by comma, I found a code with bring all values into the column, but I need only count,
    here is the code:-
    Please Login or Register  to view this content.
    thanks
    rao
    Last edited by AliGW; 04-07-2018 at 10:40 AM. Reason: Code tags added.

  8. #8
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: highlight duplicate names within single cell

    Please show a few rows example of your Data and the expected result.

  9. #9
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    hi,
    At present I am using a formula:- =SUMPRODUCT(--(D6:D17<>""),LEN(D6:D17)-LEN(SUBSTITUTE(D6:D17,",",""))+1)-(LEN(D6:D17)-LEN(SUBSTITUTE(D6:D17, "(TE)","")))/LEN("(TE)") to get my result but it is very big & if there is no value I am getting 0, I do not want 0 as a result I want blank cell if value is 0,
    to avoid all this am try to get vba codes to work, example I have a range e6:j17 filled with names separated by comma & space, few names ending with (TE)
    which I don't want to count them, from E6 to J17, I have names like Joes, Tony, Samuel, Adrian(TE), Sam, Prakash, Tony I want result in O5 =6,
    hope it is clear,
    sorry if it not,
    thanks,
    rao

  10. #10
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    Sir,
    I think, I have not example properly, in worksheet range E6:J17 their are few names separated by comma and space, I want to count number of names in that range, in the same range one or two names will ending with (TE), (TE) represents trainees, I don't want to count trainees, example from range E6:J17 I have names :- Joes, Tony, Samuel, Adrian(TE), Sam, Prakash, Tony total =7, but I want result as 6 because I don't want to count (TE). at present I am using formula to get this result {=SUMPRODUCT(--(E11:J17<>""),LEN(E11:J17)-LEN(SUBSTITUTE(E11:J17,",",""))+1)-(SUMPRODUCT(--(E11:J17<>""),(LEN(E11:J17)-LEN(SUBSTITUTE(E11:J17, "(TE)","")))/LEN("(TE)")))} it very big, can you please help me to get vba for the same.
    thanks
    rao

  11. #11
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    Hi,
    highlight duplicate names within single cell,
    sorry i facing problems with space between the names, user are giving space as they like, some time's no space and more 4 spaces and chr(10)
    so want to trim and clean the string, first loop is working well but second loop from (k in .key) get's hanging,
    please help me.

    Please Login or Register  to view this content.
    Last edited by raogm2001; 04-07-2018 at 08:07 AM.

  12. #12
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    Any one please slove my problem.

  13. #13
    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,719

    Re: highlight duplicate names within single cell

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    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, it also maintains VBA formatting.

    Click on Edit to open your thread, 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

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    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.

  14. #14
    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,719

    Re: highlight duplicate names within single cell

    Oh, dear ...

    Rule 08: Cross-posting Without Telling Us

    Your post does not comply with Rule 8 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question. If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    No further help to be offered, please, until the OP has complied with this request.

  15. #15
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    hi,
    I am sorry do not know this, please ignore my mistake, what is OP, what u want me do,

  16. #16
    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,719

    Re: highlight duplicate names within single cell

    I am sorry, but I cannot ignore your mistakes. Please read the clear instructions in both of my posts to see what you must do. These rules apply on most forums. You are the OP (original poster).

  17. #17
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell


  18. #18
    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,719

    Re: highlight duplicate names within single cell

    Thanks. Please note that you did not add the code tags I requested to post #7 - I have done it for you this time, but you must do it yourself in future.

    Please take a moment to read our rules before posting again to avoid breaking any more of them: https://www.excelforum.com/forum-rul...rum-rules.html

  19. #19
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    Thank you very much,

  20. #20
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    any one please help me.

  21. #21
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    Hi,
    highlight duplicate names within single cell,
    sorry i facing problems with space between the names, user are giving space as they like, some time's no space and more 4 spaces and chr(10)
    so want to trim and clean the string, first loop is working well but second loop from (k in .key) get's hanging,
    please help me.

    Please Login or Register  to view this content.

  22. #22
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    Quote Originally Posted by MickG View Post
    You're welcome

    Paste the code below into the active sheet code module.
    Code runs when cell altered in range "E6:J75".
    Please Login or Register  to view this content.
    Regards Mick
    sir,
    thank you very much for your above code,
    it is working fabulous so for, recently I am facing one problem, if a name is repeats more then three times
    it is highlighting other names also, like "mohan rao" repeated more then three time it is highlighting rao of other nmae like prakesh rao, please solve my problem.

    regards
    mohan

  23. #23
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    hi,
    any one please help,
    regards
    mohan

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

    Re: highlight duplicate names within single cell

    Upload a sample workbook showing before/after.

  25. #25
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    dear sir,

    1. list1
      FAIRUL
      SAMUEL
      NAVEEN JT
      HASSAN
      MOHD BILAL
    1. list2
      RABI FAIRUL
      SAMUEL JT
      NAVEEN PRASANJIT
      HASSAN ALI
      BASHIR MOHD BILAL

    sir,
    list1 and list2 both are different names separated by comma,code suppose to highlight duplicate names only, but it is highlighting both names, I hope you understood,

    regards,
    mohan.
    Attached Files Attached Files

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

    Re: highlight duplicate names within single cell

    If you categorize list1 = E6:E21, you have Hassan and Hassan Ali highlighted.

    Meanwhile, in list2 NAVEEN is not, even you have NAVEEN JT.

    What is the difference and how you determine "duplicate"?

  27. #27
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    sir,
    I am sorry uploaded wrong file,
    list 1 and list 2 are entirely two different peoples, my problem is code highlighting two different names,
    I want code to highlight same names likes FAIRUL and FAIRUL if it is duplicate not FAIRUL and RABI FAIRUL this two are, two different peoples , all the names are separated by comma.
    I hope I am clear this time.
    thanks
    mohan
    Attached Files Attached Files
    Last edited by raogm2001; 06-23-2018 at 12:18 PM. Reason: uploading sample file

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

    Re: highlight duplicate names within single cell

    1) What do you mean list1 and list2? what are they?
    2) What are Name1 & name2 in your workbook?

    You said
    all the names are separated by comma.
    Not all...

  29. #29
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    sir,
    name1,name2 and list1, list2 are same, this is for your reference, this names are highlighted in the workbook, I have written separately to explain to you,
    please check the range ("D6:L19,D23:L43") names which are highlighted.
    thanks

    mohan

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

    Re: highlight duplicate names within single cell

    You partially highlighted ;

    1) BASHIR MOHD BILAL
    2) HASSAN ALI
    3) SAMUEL JT

    Why?

  31. #31
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    sir,
    code is highlighting like that not me that is the problem, please check the code in sheet1 Worksheet_Change(ByVal Target As Range)
    in sample workbook.
    thanks
    mohan

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

    Re: highlight duplicate names within single cell

    If so, upload a workbook before/after that you expect.
    You should do it manually to show us what you have and what you expect.

    Otherwise, wasting time.

  33. #33
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    sir,
    I got this code from the same site from MickG, I thought this will help to slove my problem, I am using this code from past one year from same type of file on my daily basis, I want some modification in this code if possible,
    sir, if want make a new code I will be more happy, if you want new file I will make a new sample and upload.


    thanks

    mohan
    Last edited by raogm2001; 06-23-2018 at 01:34 PM. Reason: some text change

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

    Re: highlight duplicate names within single cell

    If you just want to modify existing code, wait someone else.

    I was to build the code from scratch. Good luck.

  35. #35
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Re: highlight duplicate names within single cell

    sir,
    please wait I am sending new sample file
    please help me, please don't leave.

    thanks
    mohan
    Attached Files Attached Files
    Last edited by raogm2001; 06-23-2018 at 01:51 PM. Reason: NEW SAMPLE FILE

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

    Re: highlight duplicate names within single cell

    1) To Sheet1 code module
    Please Login or Register  to view this content.
    2) A standard code module
    Please Login or Register  to view this content.
    Attached Files Attached Files

  37. #37
    Registered User
    Join Date
    09-06-2017
    Location
    indai
    MS-Off Ver
    2013
    Posts
    38

    Thumbs up Re: highlight duplicate names within single cell

    sir,
    thank you very much, working fabulous,


    god may bless you,


    regards,
    mohan
    Last edited by raogm2001; 06-24-2018 at 01:49 PM.

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

    Re: highlight duplicate names within single cell

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

+ 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] transpose identified duplicate names to a single row
    By p99 in forum Excel General
    Replies: 15
    Last Post: 08-14-2016, 09:53 AM
  2. [SOLVED] Highlight duplicate names in the same cell
    By Taisir in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-22-2015, 10:59 PM
  3. Replies: 5
    Last Post: 01-30-2014, 09:40 AM
  4. [SOLVED] Split contents of cell into single names then search for names on different sheet.
    By RichTea88 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 12-18-2013, 10:53 AM
  5. VBA Needed To Highlight Duplicate Info In Single Column
    By jim100361 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-20-2013, 11:37 PM
  6. Excel 2007 : Highlight certain names in a cell
    By votefourpedro in forum Excel General
    Replies: 8
    Last Post: 04-29-2011, 08:55 PM
  7. Highlight top duplicate cell
    By blade82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2010, 08:36 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