Compare Macro in Excel

Closed
Smitty - Dec 10, 2010 at 05:55 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Dec 11, 2010 at 05:55 AM
Hello,

I am trying to create a macro in Excel 2003 that will compare data in Column A to Column B. The cells that are in column A and B will vary each time. I need to find duplicates entries between Column A & B and then output the NON-Duplicates into Column D, leaving Column C blank. It also would be nice to have Column D bolded and change color but that is the least of my worries at his point. Please help!!


Related:

1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Dec 11, 2010 at 05:55 AM
supposse the data is similar to the follwing from A1 down and in column B(NO header row)

a a
s d
d g
f
g
h


now try this macro

Sub test()
Dim r As Range, c As Range, cfind As Range, dest As Range, x As String
Columns("D:D").Delete
Set r = Range("A1").CurrentRegion
For Each c In r
If WorksheetFunction.CountIf(r, c.Value) = 1 Then
c.Copy
Set dest = Cells(Rows.Count, "D").End(xlUp).Offset(1, 0)
dest.PasteSpecial
End If
Next c
End Sub
0