Hi,
I've got two workbooks ExtOrgsList.xlsx contains an ID of a Customer. The ID is in Column A and the Customer name is in Column B.
Destination.csv has column AN which contains the Customer names.
The code below works but if there's any deviation in the name it returns the partial match. Upper case or lower case doesn't matter but it should match the whole text.
How to add that in the below code plus if search doesnt match return a value "** Check the External Orgs **"
ExtOrgsList
Destination.csv
After the code Destination.csv should have the data below
BUT currently I'm getting this data
I've got two workbooks ExtOrgsList.xlsx contains an ID of a Customer. The ID is in Column A and the Customer name is in Column B.
Destination.csv has column AN which contains the Customer names.
The code below works but if there's any deviation in the name it returns the partial match. Upper case or lower case doesn't matter but it should match the whole text.
How to add that in the below code plus if search doesnt match return a value "** Check the External Orgs **"
ExtOrgsList
A | B |
---|---|
310001 | Employer Services |
310002 | Construction Worldwide Services |
310003 | Construction Worldwide |
310004 | Employer Name 4 |
Destination.csv
AN |
---|
Employer Services |
Construction Worldwide Services |
Construction Worldwide |
Employer Name 4 |
Employer Name 5 |
After the code Destination.csv should have the data below
AN |
---|
310001 |
310002 |
310003 |
310004 |
** Check The External Orgs ** |
BUT currently I'm getting this data
AN |
---|
310001 |
310002 |
310002 |
310004 |
VBA Code:
Dim Cl As Range
Dim Dic As Object
Set Dic = CreateObject("scripting.dictionary")
With wsExtOrgsList
For Each Cl In .Range("B5", .Range("B" & Rows.Count).End(xlUp))
Dic(Cl.Value) = Cl.Offset(, -1).Value
'Dic(Cl.Value) = Cl.Value
Next Cl
End With
With wsDest
For Each Cl In .Range("AN2", .Range("AN" & Rows.Count).End(xlUp))
'If Dic.exists(Cl.Value) Then Cl.Offset(, 1).Value = Dic(Cl.Value)
If Dic.exists(Cl.Value) Then Cl.Value = Dic(Cl.Value)
Next Cl
End With