# Assistance needed - Pattern Matching question (repost)

#### mikelopez

##### Board Regular
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.

 ZYLOG SYSTEMS (INDIA) LIMITED. ZYTEL INVESTMENTS LIMITED ZYLOG PLASTALLOYS PRIVATE LIMITED ZYRON WEALTH MANAGEMENT SERVIC ZUVENTUS HEALTHCARE LIMITED ZYLOG SYSTEMS

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

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:

#### RickXL

##### MrExcel MVP

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.

#### Jeffrey Smith

##### Well-known Member
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

1,081,617
Messages
5,360,049
Members
400,565
Latest member
Tommy O

### This Week's Hot Topics

• VBA (Userform)
Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
• List box that changes fill color
Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
• Remove duplicates and retain one. Cross-linked cases
Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
• VBA Copy and Paste With Duplicates
Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
• Macro
is it possible for a macro to run if the active cell value is different to the value above it
• IF DATE and TIME
I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...