+ Reply to Thread
Results 1 to 12 of 12

% similarity between 2 cells of text

  1. #1
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    % similarity between 2 cells of text

    Is there a method or formula of working out how similar the data is in two cells?
    i.e. Cell A1 has "Mr John Moore" and Cell B1 has "John Moore" What is the percentage of similarity between these 2 cells?

    Thank you
    Last edited by guerillaexcel; 06-16-2010 at 10:55 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: % similarity between 2 cells of text

    Below is a UDF (stored in a Module in VBE)

    Please Login or Register  to view this content.
    called from a cell along the lines of:

    Please Login or Register  to view this content.
    compares B1 to A1 - in this case returning 67%
    (case sensitivity is optional)

    Modify as appropriate.

  3. #3
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    Re: % similarity between 2 cells of text

    Cheers DonkeyOte, pardon my ignorance but do I copy the UDF to a module in excel and then use the Compare String.

    Thanks very much btw!

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: % similarity between 2 cells of text

    Yes, the Function would sit in a Module and then (in macro enabled file) you can call the function from a cell as outlined.

    You might find the code doesn't do exactly what you want (it was configured for someone else a while back with specific requirements), however, hopefully it will help to some extent.

  5. #5
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    Re: % similarity between 2 cells of text

    Thanks, I've not done something like this before.
    Ok, just tried it and its returning #NAME? in the comparestring cell.
    Any ideas? (I know Im doing something stupid here..)

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: % similarity between 2 cells of text

    Are Macros enabled ?

    Did you store the UDF in a standard Module in VBE ? (eg Module1)


    #NAME? generally results because the function name used is not recognised as "valid".

  7. #7
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    Re: % similarity between 2 cells of text

    I'm assuming that macros are enabled as I can run them, but can I check that they are to be sure? And I copied and pasted the UDF into Module25. Would that be the problem?

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: % similarity between 2 cells of text

    For demo. see attached.

    (if you get #NAME? errors with said attachment then VBA is not enabled)
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    09-18-2008
    Location
    Scotland
    Posts
    156

    Re: % similarity between 2 cells of text

    Fantastic Donkey, cheers!!!
    I'm an idiot btw :S
    I had copied the UDF into a module on a different spreadsheet :D
    and the worksheet wasn't named Sheet1.
    Its working perfectly now, thanks very much!

  10. #10
    Registered User
    Join Date
    12-23-2014
    Location
    Rotterdam
    MS-Off Ver
    2010
    Posts
    1

    Re: % similarity between 2 cells of text

    % similarity between 2 cells of text, that was exactly my question. Many Thanks! regards, Jake

  11. #11
    Registered User
    Join Date
    03-12-2015
    Location
    UK
    MS-Off Ver
    excel
    Posts
    3

    Re: % similarity between 2 cells of text

    How this macro has to be changed if
    I want to ignore prefix dot and it will give percent also if the words has wroten without space.

    Column B = I have http://www. ( i want percent compare of domain name ) .com
    Column A = Normal letters expect one prefix / which would be nice to ignore

    Would it be possible ?
    thanks : )

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,047

    Re: % similarity between 2 cells of text

    Pavbo, welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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