+ Reply to Thread
Results 1 to 11 of 11

Compare character strings in 2 cells and return only the differences

  1. #1
    Registered User
    Join Date
    03-06-2015
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    6

    Compare character strings in 2 cells and return only the differences

    Hi all,

    Was hoping someone could provide some help with a problem I've been working on. I have a data set that contains very similar data save for one or 2 characters. I'm trying to isolate those characters using a formula but can't seem to figure out a proper way to do that.

    For example

    Example 1

    Cell 1 - CARA123
    Cell 2 - CARA123#

    (in this example, i'd like the cell to indicate # as the unmatched character)

    Example 2

    Cell 1 - ARNA<
    Cell 2 - ARNA

    (in this example, i'd like the cell to indicate < as the unmatched character)


    Another possibility that may solve my dilemma is a formuala that will compare each character in the cell one by one and only bring back the results starting where the differences occur.

    For example

    Cell 1 - ARNAFED123
    Cell 2 - ARNABED123

    The formula would then bring back BED123 as the answer (as the B was the point where the 2 cells "became unmatched").

    Any help provided would be greatly appreciated.

  2. #2
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Compare character strings in 2 cells and return only the differences

    This is assuming that one cell contains the "correct" version of how the text should look. Which cell would contain that?
    Spread the love, add to the Rep

    "None of us are as smart as all of us."

  3. #3
    Registered User
    Join Date
    03-06-2015
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    6

    Re: Compare character strings in 2 cells and return only the differences

    Well, I don't want to say that one cell is right and one cell is wrong but for the sake of this example, let's say that the cell with the "character" is wrong.

  4. #4
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Compare character strings in 2 cells and return only the differences

    What I mean is, for text that don't match character length, it is easy to single out the extra characters. However, for text lengths that match, such as your last example, why would it be BED123 that is the answer, as opposed to FED123?

  5. #5
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Compare character strings in 2 cells and return only the differences

    Just a rough format of what you required...
    Sorry if this is not what you need...
    Attached Files Attached Files
    Happy to Help

    How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html

    "I don't get things easily, so please be precise and elaborate"

    If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
    If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.

    Sourabh

  6. #6
    Registered User
    Join Date
    03-06-2015
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    6

    Re: Compare character strings in 2 cells and return only the differences

    Quote Originally Posted by mcmahobt View Post
    What I mean is, for text that don't match character length, it is easy to single out the extra characters. However, for text lengths that match, such as your last example, why would it be BED123 that is the answer, as opposed to FED123?
    Yeah I think that 2nd example was very unclear. I guess I'm going on the assumption that cell 1 is correct....but it was a completely different scenario.

  7. #7
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Compare character strings in 2 cells and return only the differences

    Amazing formula sourabgh98.

    Maybe to make it work both ways:

    Please Login or Register  to view this content.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  8. #8
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Compare character strings in 2 cells and return only the differences

    It is better if you attach a sample excel file with some examples and your expected result
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  9. #9
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Compare character strings in 2 cells and return only the differences

    @daffodil
    thanks for your feedback...and further improving the formula.....

  10. #10
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Compare character strings in 2 cells and return only the differences

    if you have data in Cell A1 and Cell A2 then try
    =IFERROR(MID(IF(LEN(A2)>=LEN(A1),A2,A1),MATCH(FALSE,INDEX(ISNUMBER(SEARCH(LEFT(IF(LEN(A2)>=LEN(A1),A2,A1),ROW($1:$50)),IF(LEN(A2)>=LEN(A1),A1,A2))),0),0),256),"")
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    03-06-2015
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    6

    Re: Compare character strings in 2 cells and return only the differences

    Sorry for the late response everyone. Thank you so much for all the help!

    I was able to produce the results i needed using the first formula. I'm still messing around with all of them though to see how I could apply them to the existing data set (or future data sets).

    You've all been an amazing 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] Compare Two Cells & Return Whats Common Between the two strings and delete the variation
    By alfykunable in forum Excel Programming / VBA / Macros
    Replies: 34
    Last Post: 10-24-2020, 02:00 PM
  2. Replies: 1
    Last Post: 03-06-2015, 01:07 PM
  3. Compare two strings and output the differences
    By aliastx in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-14-2013, 10:49 PM
  4. Compare Differences between 2 strings
    By wadafruck in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-11-2012, 07:09 PM
  5. Compare Worksheets and Return Differences
    By bkeller83 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-16-2009, 01:52 AM

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