Compare columns for dupes

M

Martin

Hi all,

This is probably something very simple. I have two columns that I need to
compare for duplicates. So I have columns A and B, I need a macro that will
compare the data in column A with the data in column B then copy any
duplicates to column C.

Can someone provide some code?

Thanks.

-B
 
M

Martin

Thanks I found this code on Microsoft's website and it seems to work,
however, I'd like to add a regex procedure that would match wildcards, etc.

If someone can provide an example, I would appreciate it.

Sub Find_Matches()

Dim CompareRange As Variant, x As Variant, y As Variant

Set CompareRange = Range("C1:C5")

For Each x In Selection
For Each y In CompareRange
If x = y Then x.Offset(0, 1) = x
Next y
Next x

End Sub

-B

in C1

=if(countif(A:A,B1)>0,B1,"")

then drag fill down the column.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top