Compare two column

psamu

Active Member
Joined
Jan 3, 2007
Messages
462
I have two column in excel I want find column differences ; I have below two column I want to find out based on the employee name check entire Manager column find any differences in manager name.

Emp Name Manger

Mike John
Mike Victor
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Do you want to know which employee names are not manager names?
 
Upvote 0
I'm assuming that the Employee Name is in column A and the manager is on column B. This will highlight in red every employee who is not a manager.
Code:
Sub CompareLists()
    Application.ScreenUpdating = False
    Dim Rng As Range, RngList As Object
    Set RngList = CreateObject("Scripting.Dictionary")
    For Each Rng In Range("B1", Range("B" & Rows.Count).End(xlUp))
      If Not RngList.Exists(Rng.Value) Then
        RngList.Add Rng.Value, Nothing
      End If
    Next Rng
    For Each Rng In Range("A1", Range("A" & Rows.Count).End(xlUp))
      If Not RngList.Exists(Rng.Value) Then
        Rng.Font.ColorIndex = 3
      End If
    Next Rng
    RngList.RemoveAll
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
I'm assuming that the Employee Name is in column A and the manager is on column B. This will highlight in red every employee who is not a manager.
Code:
Sub CompareLists()
    Application.ScreenUpdating = False
    Dim Rng As Range, RngList As Object
    Set RngList = CreateObject("Scripting.Dictionary")
    For Each Rng In Range("B1", Range("B" & Rows.Count).End(xlUp))
      If Not RngList.Exists(Rng.Value) Then
        RngList.Add Rng.Value, Nothing
      End If
    Next Rng
    For Each Rng In Range("A1", Range("A" & Rows.Count).End(xlUp))
      If Not RngList.Exists(Rng.Value) Then
        Rng.Font.ColorIndex = 3
      End If
    Next Rng
    RngList.RemoveAll
    Application.ScreenUpdating = True
End Sub

Thanks
 
Upvote 0
Sorry, I for the confusion. Column A Employees ID, Column B has Manager Name, Column A Employees ID has multiple times, (can be many times repeated), I am looking for If Column A Employee ID is same and managers Name are different in Column B.
Eg, ID 123 Manager is Mike, and another record shows Employee ID123 but Manager is John. If Manager is same for both, do not high light. Hope this is clear. Thank you.
 
Upvote 0
Can there be more than 2 manager names for any one employee ID?
 
Upvote 0
Let's say you have something like the following:

ID Manager Name
1 Mike
1 George
1 Mike
1 George
2 John
2 Mary
2 John
2 Mary
2 John

There are 4 people with an ID of "1" where 2 of the people have Mike as a manager and 2 have George as a manager. How do you decide which to highlight? Same for ID "2".
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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