Compare text between two cols

Panchistiko

New Member
Joined
Oct 22, 2009
Messages
37
Hello everyone,

I have these columns with about 50000 names, and I need to determine whether the SIMPLE NAME matches the FULL NAME, with at least two words, in any order.
In col C, I’d expect a “YES” if the names match, otherwise a “NO”.
If match just one word, it’s a “NO”



Book1
ABC
1FULL NAMESimple NameMatch
2GONZALO MARCO PEREZ .Gonzalo M PerezYes
3RUBEN ARMENIO ESPINOZA ESTERNEspinoza RubenYes
4DIANA MARIA DIAZ AGUILERADiana M DiazYes
5CARLA RAMIRA HERNANDEZ LOZClaudia R HernandezNo
6MARGARITA FERRER COVARRUBIASFerrer MonicaNo
7ANA LUIS COLONNA LORENZINIColonna AnaYes
8DIEGA YOLANDA AMAYA BOLOADiana AmayaNo
9LIDIA CARMEN HINCAPIE VENEGASLidia HincapieYes
Sheet1



Thank you all.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Here's a UDF (lightly tested) you can try with an example below.
Excel Workbook
ABC
1FULL NAMESimple NameMatch
2GONZALO MARCO PEREZ .Gonzalo M PerezYes
3RUBEN ARMENIO ESPINOZA ESTERNEspinoza RubenYes
4DIANA MARIA DIAZ AGUILERADiana M DiazYes
5CARLA RAMIRA HERNANDEZ LOZClaudia R HernandezNo
6MARGARITA FERRER COVARRUBIASFerrer MonicaNo
7ANA LUIS COLONNA LORENZINIColonna AnaYes
8DIEGA YOLANDA AMAYA BOLOADiana AmayaNo
9LIDIA CARMEN HINCAPIE VENEGASLidia HincapieYes
Sheet6

To install the Function:
1. With your workbook active press Alt and F11 keys. This will open the VBE window.
2. In the project tree on the left of the VBE window, find your project and click on it.
3. On the VBE menu: Insert>Module
4. Copy the code from your browser window and paste it into the white space in the VBE window.
5. Close the VBE window and Save the workbook. If you are using Excel 2007 or a later version do a SaveAs and save it as a macro-enabled workbook (.xlsm file extension).
6. Press Alt+F8 keys to run the code
7. Make sure you have enabled macros whenever you open the file or the code will not run.
Code:
Function MatchTwo(Full As String, Simple As String) As String
Dim B As Boolean, S1 As Variant, S2 As Variant, ct As Long, i As Long, j As Long
S1 = Split(Full, " ")
S2 = Split(Simple, " ")
For i = LBound(S1) To UBound(S1)
    For j = LBound(S2) To UBound(S2)
        If LCase(S2(j)) = LCase(S1(i)) Then
            ct = ct + 1
            If ct = 2 Then
                B = True
                Exit For
            End If
        End If
    Next j
    If B Then
        MatchTwo = "Yes"
        Exit Function
    End If
Next i
If Not B Then MatchTwo = "No"
End Function
 
Upvote 0
If you wish to have formulas, this will suffice. Copy C2 downward.

I would like to note that you might encounter some problems with your parameters. For example, what would you do if Gonzalo Y Perez was the Simple Name - would that be a match or not?

ABC
FULL NAMESimple NameMatch
GONZALO MARCO PEREZGonzalo M Perez
RUBEN ARMENIO ESPINOZA ESTERNEspinoza Ruben
DIANA MARIA DIAZ AGUILERADiana M Diaz
CARLA RAMIRA HERNANDEZ LOZClaudia R Hernandez
MARGARITA FERRER COVARRUBIASFerrer Monica
ANA LUIS COLONNA LORENZINIColonna Ana
DIEGA YOLANDA AMAYA BOLOÑADiana Amaya
LIDIA CARMEN HINCAPIE VENEGASLidia Hincapie

<tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]

[TD="bgcolor: #A9D08E"]Yes[/TD]

[TD="align: center"]3[/TD]

[TD="bgcolor: #A9D08E"]Yes[/TD]

[TD="align: center"]4[/TD]

[TD="bgcolor: #A9D08E"]Yes[/TD]

[TD="align: center"]5[/TD]

[TD="bgcolor: #A9D08E"]No[/TD]

[TD="align: center"]6[/TD]

[TD="bgcolor: #A9D08E"]No[/TD]

[TD="align: center"]7[/TD]

[TD="bgcolor: #A9D08E"]Yes[/TD]

[TD="align: center"]8[/TD]

[TD="bgcolor: #A9D08E"]No[/TD]

[TD="align: center"]9[/TD]

[TD="bgcolor: #A9D08E"]Yes[/TD]

</tbody>
Sheet11

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH="width: 10"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]C2[/TH]
[TD="align: left"]=IF(ISNUMBER(SEARCH(LEFT(B2,SEARCH(" ",B2)-1),A2)+SEARCH(IF(ISERROR(MID(B2,SEARCH(" * ",B2),3)),MID(B2,SEARCH(" ",B2)+1,100),MID(B2,SEARCH(" * ",B2)+3,100)),A2)),"Yes","No")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Hi DRSteel,
Thank you for your reply.

It worked out pretty well, but, how come this examples returned a "NO", when they do match.



Book1
ABC
1FULL NAMESIMPLE NAMEMATCH
2MONICA DIANA PIRRAS CARPACCIOMonica Diana Pirras CarpaccioNo
3MARIANA ALBERTA HERNANDEZ .Mariana Hernandez [Manager - PE]No
4YAMIL LUTIO CABALLOS MANODA .Yamil Lutio Caballos [Tienda 2 - CL]No
5DIEGO LUZ MARCHANT .Diego Luiz Marchant [Tienda X - CO]No
Sheet2
 
Upvote 0
Why does it return "No" now? Because your Simple Name format has changed radically from your original example: now you've got some with four words, some with middle names instead of just a space-initial-space and some with a plethora of spaces.

I don't even know how to tackle this complex task. VBA from a genius is what you'll need.
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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