View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default common numbers in 2 columns

Highlight Duplicates with Conditional Formatting:-

Assuming that the first range is A1:A800 and the second range is in column B
starting at B1:
1. Select all the cells of the second range (column B)
2. Select Format Conditional Formatting
3. Select "Formula Is" from the left dropdown
4. Paste this formula (use Ctrl + V to paste):
=COUNTIF($A$1:$A$800, B1) 0
5. Click the Format button and select the desired format option
6. Click OK to close the Format Cells dialog
7. Click OK to close the Conditional Formatting dialog

Note that if the either range will change in size then using a dynamic named
range is suggested. See http://www.contextures.com/xlNames01.html#Dynamic

Macro that Copies Duplicates to a Third Column:-

Sub CopyDups()
Dim r1 As Range, r2 As Range, r3 As Range
Dim c As Range

Set r1 = Range(Range("A1"), Range("A1").End(xlDown))
Set r2 = Range(Range("B1"), Range("B1").End(xlDown))
For Each c In r2.Cells
If Application.CountIf(r1, c) 0 Then
If r3 Is Nothing Then
Set r3 = Range("C1")
r3 = c.Value
Else
If Application.CountIf(r3, c) = 0 Then
Set r3 = r3.Resize(r3.Count + 1, 1)
r3(r3.Count, 1) = c.Value
End If
End If
End If
Next
End Sub

Note that the above macro shouldn't list duplicates more than once if they
are repeated in the first (larger) range. Also note that it was written just
now (for you) in a hurry with minimal testing. It should be tested
rigorously. That's your job. Change range references to suit. Hope it does
the job.

Regards,
Greg


"aubudgo" wrote:

I have two columns of numbers. One is a large list with say 3,000
random
serial numbers. The other is a smaller list of 800 serial numbers. I
want to
find if any serial numbers are listed in both of the columns. I want to
identify which number appear in both columns and move them to another
column, or at least highlight them. I tried to follow the advice given
to an earlier post but could not make it work for me: perhaps I need a
simpler or more detailed explanation.