Compare if exact match return the ID adjacent to it

Razor_Rob

Board Regular
Joined
Aug 18, 2022
Messages
65
Office Version
  1. 365
Platform
  1. Windows
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
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
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Sorry change of logic if data doesnt match it should display ** Check The External Orgs **, it should just leave the current data (Employer Name)
 
Upvote 0
I got this working, but I want the search/comparison not be case sensitive, like if the text in the Column B is all in upper case or lower case it. Can someone please help ?

Thanks in advance
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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