+ Reply to Thread
Results 1 to 9 of 9

Searching for same characters in two cells

  1. #1
    Registered User
    Join Date
    03-20-2010
    Location
    UK
    MS-Off Ver
    365 for Mac, 16.82
    Posts
    12

    Searching for same characters in two cells

    Hello

    I am trying to work out a way of finding out if two cells have any characters in common.

    For example, in cell A1 I have the string ABCDEF in it. In A2 I have ACEFG. Both cells have the characters A, C, E and F present and would therefore return TRUE.

    Is there anyway to do this in a concise formula?

    Many thanks for your help in advance

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,058

    Re: Searching for same characters in two cells

    One way:

    =IF(SUM(--ISNUMBER(MATCH(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),MID(B1,ROW(INDIRECT("1:"&LEN(B1))),1),0)))>0,TRUE,"")
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    03-20-2010
    Location
    UK
    MS-Off Ver
    365 for Mac, 16.82
    Posts
    12

    Re: Searching for same characters in two cells

    Ooof! A bit longer than I was hoping for but at least it does the job.

    Thank you very much!

  4. #4
    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,916

    Re: Searching for same characters in two cells

    What does the length matter??? That's not long - it's pretty average in length, actually.

    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 those who helped.
    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.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,058

    Re: Searching for same characters in two cells

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

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

  6. #6
    Registered User
    Join Date
    03-20-2010
    Location
    UK
    MS-Off Ver
    365 for Mac, 16.82
    Posts
    12

    Re: Searching for same characters in two cells

    The length matters as it may not always be me maintaining it. Whilst I can understand what it is doing, someone with less experience has a much larger knowledge-gap to overcome to understand what the formula is doing.

    Also, as any programmer will tell you, you should try to be efficient with your code. If this is as efficient as possible that's totally fine, it just has a few minor drawbacks.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,058

    Re: Searching for same characters in two cells

    Question. Are all the strings the same length, by any chance??

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,058

    Re: Searching for same characters in two cells

    Here's a better alternative....

    =IF(SUM(--ISNUMBER(MATCH(MID(A1,SEQUENCE(LEN(A1)),1),MID(B1,SEQUENCE(LEN(B1)),1),0)))>0,TRUE,"")

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Searching for same characters in two cells

    Another option
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    If it shouldn't be case sensitive (ie a=A) then change find to search

+ 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] searching using few characters
    By gencoglu27 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-23-2017, 09:47 AM
  2. Searching a text box for characters and replace.
    By sungen99 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-08-2015, 02:29 PM
  3. [SOLVED] Searching Special Characters
    By shyam sundar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-25-2014, 04:13 PM
  4. Replies: 4
    Last Post: 07-26-2011, 08:22 PM
  5. Replies: 1
    Last Post: 05-23-2011, 04:22 AM
  6. Searching each cell for any combination of 3 characters
    By ravl13 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-08-2010, 10:39 AM
  7. searching characters problem
    By Deci in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-28-2007, 05:44 PM

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