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.
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: