compare 2 columns and display the difference in 3rd column and similar in 4th

torrents

New Member
Joined
Dec 15, 2011
Messages
4
compare 2 (A & C) columns with numbers and display the numbers that are in the first column and not in the second column in the column E

then display the numbers that are in both columns (A & C) in column G
 
Last edited:

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
How about
Code:
Sub torrents()
   Dim Cl As Range
   Dim Ky As Variant
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = False
      Next Cl
      For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
          If .Exists(Cl.Value) Then .Item(Cl.Value) = True
      Next Cl
      For Each Ky In .Keys
         If .Item(Ky) Then
            Range("G" & Rows.Count).End(xlUp).Offset(1).Value = Ky
         Else
            Range("E" & Rows.Count).End(xlUp).Offset(1).Value = Ky
         End If
      Next Ky
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,002
Messages
6,122,652
Members
449,092
Latest member
peppernaut

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