Assistance needed - Pattern Matching question (repost)

mikelopez

Board Regular
Joined
Sep 9, 2013
Messages
58
Hello everyone

I have a list of company names that I would like to match up to a list of other company names. The list in column A goes from A2 to A11087. The list in column B goes from B2 to B57013.

What I am trying to accomplish is I want to create a some kind of macro code such as the one written below and use said fromula to give me the exact or similar company names in column C no matter if, for example, the company name in column A2 is similar to the one in column B2 or not.

So for example if the company name in A2 is not similar or the exact match in B2 but the exact match or similar name is found in B3 or even B4 then I want the similar or the exact match to appear in the corresponding C cell.

What changes in the below code can I make to help me accomplish this?

This is the code:

Function FindSimilar(R As Range) As String
Dim Cel As Range
Dim AStr(20) As String
Dim X As Long
Dim Y As Long
Dim Numbers As String
Dim BStr(20) As String
Dim S As Integer
Dim NumCells As Integer
Dim FS As String

Numbers = "0123456789"

X = 0
For Each Cel In R
X = X + 1
AStr(X) = Cel.Text
AStr(X) = Replace(AStr$(X), " ", "")
For Y = 1 To 10
AStr(X) = Replace(AStr$(X), Mid$(Numbers, Y, 1), "")
Next Y
Next Cel
NumCells = X

BStr(1) = AStr(1)
S = 1
If InStr(AStr(1), " ") > 0 Then
S = 4
BStr(2) = Left$(AStr(1), InStr(AStr(1), " ") - 1)
BStr(3) = Mid$(AStr(1), InStr(AStr(1), " ") + 1)
BStr(4) = Replace(AStr(1), " ", "")
End If


FS = ""
For Y = 1 To S
If Y = 2 Or Y = 3 Then
If InStr(AStr(2), BStr(2)) > 0 And InStr(AStr(2), BStr(3)) > 0 Then
FS = BStr(2) & " " & BStr(3)
End If
ElseIf InStr(AStr(2), BStr(Y)) > 0 Then
FS = BStr(Y)
End If
If Len(FS) > 0 Then Exit For

Next Y

If Len(FS) = 0 Then FS = "9999"

FindSimilar = FS

End Function


Here is what part of my spreadsheet looks like.

[TABLE="width: 1037"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]ZYLOG SYSTEMS (INDIA) LIMITED.[/TD]
[TD]ZYTEL INVESTMENTS LIMITED[/TD]
[/TR]
[TR]
[TD]ZYLOG PLASTALLOYS PRIVATE LIMITED[/TD]
[TD]ZYRON WEALTH MANAGEMENT SERVIC[/TD]
[/TR]
[TR]
[TD]ZUVENTUS HEALTHCARE LIMITED[/TD]
[TD]ZYLOG SYSTEMS
[/TD]
[/TR]
</tbody>[/TABLE]

What I want to set out to accomplish is simply this:

If zylog systems (India) is in A2 for example, I want to create a macro formula that will search all of the B column for the exact name or similiar name to what is in column A2 and put the out put in C2. For example the output in C2 should be ZYLOG SYSTEMS since ZYLOG SYSTEMS is only similar to ZYLOG SYSTEMS (INDIA) LIMITED.
 
Last edited:

Excel Facts

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

You could count the number that match and the highest ranking would be the most likely. You could weight words so that LIMITED or SYSTEMS weighed less than words like ZYLOG.
 
Upvote 0
I guess you didn't see my other post. Or you chose to ignore it. Why would you cross post like that? Patience is a virtue.

C'est la vie

Jeff
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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