Compare 2 column of names

shimaa01234

Active Member
Joined
Jun 24, 2014
Messages
446
I want to write "Yes" if match the first name of the column "A" with the first name of the column "B"
And write "Yes" if the two match the name of the column "A" with a name of the column "b" etc. .........
And writing "no" if you do not similar to anything of Name

NAME1NAME2RESULT
AAABBAACYES
CABCDCHIJKYES
FGLMDSERNO
XYUZXYUZYES

<colgroup><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
.
.

Try this UDF:

Code:
Function SIMILAR(text1 As String, _
    text2 As String, _
    Optional case_sensitive = False)

    Dim i As Byte
    Dim chars As Byte
    
    chars = WorksheetFunction.Min( _
        Len(text1), _
        Len(text2))
    
    If chars < 1 Then Exit Function
    
    For i = 1 To chars
        If case_sensitive Then
            If Mid(text1, i, 1) = _
                Mid(text2, i, 1) Then
                SIMILAR = True
                Exit Function
            End If
        Else
            If LCase(Mid(text1, i, 1)) = _
                LCase(Mid(text2, i, 1)) Then
                SIMILAR = True
                Exit Function
            End If
        End If
    Next i
    
    SIMILAR = False

End Function
 
Upvote 0
shimaa01234,

If I have understood correctly then perhaps....

Excel 2007
ABCD
1NAME1NAME2RESULT 1Not Case Sensitive
2AAABBAACYESYES
3CABCDCHIJKYESYES
4FGLMDSERNONO
5XYUZXYUZYESYES
6xYUZXYUZNOYES
Sheet1
Cell Formulas
RangeFormula
C2=IF(ISNUMBER(FIND(LEFT(A2,1),B2)),"YES","NO")
D2=IF(ISNUMBER(SEARCH(LEFT(A2,1),B2)),"YES","NO")


Column C formula being case sensitive column D not.

Hope that helps.
 
Upvote 0
Unfortunately Mister "gpeacock"
Unfortunately, Mister " Snakehips"
Formulas did not work well because the names in the example, not the real names
But the example of the names
because one Name a component of many of the characters

NAME1NAME2RESULT
Peter Gabriel RichardPeter Gabriel MikhailYES
Peter Anthony Abdel MassihPeter Anthony Abdel MassihYES
Antoniades conclude MikhaúielSarah Jad'aanNO
Peter Gabriel RichardPeter Gabriel RichardYES

<colgroup><col><col><col></colgroup><tbody>
</tbody>
 
Last edited:
Upvote 0
Then in order for anyone to give you a more meaningful answer you must post a more meaningful example of your original data and your desired result.
 
Upvote 0
Unfortunately, Mister " Snakehips"
I imagined that example enough to resolve, a special solution that relies on the similarity of first name or first and second, or first, second and third
 
Upvote 0
My apologies. It would appear that you added the 'meaningful' example as an edit that I did not see before making my last post.
 
Upvote 0
shimaa01234, gpeacock,

I was thinking that Mister "peacock" 's SIMILAR () UDF was what you needed, even though you have stated that it does not work.
In the example below, column D, it appears to work other than in row it thinks there is similarity between Mickey Mouse and Peter Gabriel Richard !!???

Does my UDF CompNames as in column C, do what you are wanting?

Excel 2007
ABCD
1NAME1NAME2RESULTSIMILAR Function???
2peter gabriel mikhailPeter Gabriel MikhailYESYES
3Peter Anthony Abdel MassihPeter Anthony Abdel MassihYESYES
4Antoniades conclude MikhaielSarah Jad'aanNONO
5Peter Gabriel RichardPeter Gabriel RichardYESYES
6John Gabriel RalphPeter Gabriel RichardYESYES
7John Peter RalphPeter Gabriel RichardYESYES
8Mickey MousePeter Gabriel RichardNOYES
9Peter Gabriel RichardPeter Gabriel RichardYESYES
10NO
11NO
Sheet2
Cell Formulas
RangeFormula
C2=CompNames(A2,B2)
D2=IF(SIMILAR(A2,B2),"YES","NO")

I can add a case sensitivity option if it is required.

Hope that helps.
 
Upvote 0
What a Charlie!!!!!!

I forgot to post the UDF code :oops:

In the vba editor, insert a Code Module and paste this code to it...

Code:
Function CompNames(Rng1 As Range, Rng2 As Range) As String


If Rng1 = Rng2 And Rng1.Value = "" Then
CompNames = ""
Exit Function
End If


n1 = Split(UCase(Rng1))
n2 = Split(UCase(Rng2))


CompNames = "NO"
For c1 = 0 To UBound(n1)
For c2 = 0 To UBound(n2)
If n1(c1) = n2(c2) Then
CompNames = "YES"
Exit Function
End If
Next c2
Next c1
End Function
 
Upvote 0

Forum statistics

Threads
1,214,586
Messages
6,120,402
Members
448,958
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top