ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Similar vs. Exact comparison (https://www.excelbanter.com/excel-programming/338873-similar-vs-exact-comparison.html)

dave in Toronto

Similar vs. Exact comparison
 
I'd like to compare two cells (or more possibly) for similarity vs. exact.
e.g. a cell with the i.d. of 'johnsmith' is not exactly equal to 'johnsmith2'.

Is there a way in excel to compare two cells and see if they are similar?
Maybe even some kind of confidence level flag? (or is this a fantasy?)

thanks,
dave


Chip Pearson

Similar vs. Exact comparison
 
You can use the Like operator with a wildcard character. E.g.,


Dim S As String
Dim T As String
S = "johnsmith"
T = "johnsmith1"
Debug.Print T Like "*" & S & "*"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"dave in Toronto" wrote
in message
...
I'd like to compare two cells (or more possibly) for similarity
vs. exact.
e.g. a cell with the i.d. of 'johnsmith' is not exactly equal
to 'johnsmith2'.

Is there a way in excel to compare two cells and see if they
are similar?
Maybe even some kind of confidence level flag? (or is this a
fantasy?)

thanks,
dave




Tom Ogilvy

Similar vs. Exact comparison
 
Nothing built in like Soundex

http://www.j-walk.com/ss/excel/tips/tip77.htm
John Walkenbach's page with sample VBA code.

but you can use wildcards with some functions

Excel does have the EXACT function which will test for an exact match.

--
Regards,
Tom Ogilvy



"dave in Toronto" wrote in message
...
I'd like to compare two cells (or more possibly) for similarity vs. exact.
e.g. a cell with the i.d. of 'johnsmith' is not exactly equal to

'johnsmith2'.

Is there a way in excel to compare two cells and see if they are similar?
Maybe even some kind of confidence level flag? (or is this a fantasy?)

thanks,
dave




John Keith[_2_]

Similar vs. Exact comparison
 
If the "like" comparison isnt enough,
Here is a link to a page that has a VB function to calculate the similarity
between two strings. This is a way to determine how closely matched any two
strings are. It works be determining the number of incremental edits
required to transform the first string into the second string.

http://www.merriampark.com/ld.htm

--
Regards,
John


"dave in Toronto" wrote:

I'd like to compare two cells (or more possibly) for similarity vs. exact.
e.g. a cell with the i.d. of 'johnsmith' is not exactly equal to 'johnsmith2'.

Is there a way in excel to compare two cells and see if they are similar?
Maybe even some kind of confidence level flag? (or is this a fantasy?)

thanks,
dave



All times are GMT +1. The time now is 08:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com