Find duplicates in worksheet


Posted by unstuck2 on July 18, 2001 10:51 AM

Hi,
I need a method for locating and flaging, removing or copying out duplicates in a list.
After a search the method listed in the following post in the archives is very close to what I need:

Re: Compare to find duplicates within worksheet - David Hawley 04:46:13 05/16/01 (1)
Sub CopyUniquesToNewSheet()
'Written by OzGrid Business Applications
'www.ozgrid.com

''''''''''''''''''''''''''''''''''''''''''
'Create a Worksheet
'Extract unique entries only
'Then copy the entire rows to
'the new sheet
''''''''''''''''''''''''''''''''''''''''''
Dim RUniqueCells As Range

'Add a new sheet and name it
'If already exists then rename it
On Error Resume Next
Sheets.Add().Name = "Unique Copies"
If ActiveSheet.Name <> "Unique Copies" Then
ActiveSheet.Name = "Unique Copies" & Sheets.Count
End If
On Error GoTo 0

With Sheet1
'Set Range variable to all entries
Set RUniqueCells = Range(.Range("A1"), .Range("A65536").End(xlUp))
'Advance filter to remove duplicates
RUniqueCells.AdvancedFilter _
Action:=xlFilterInPlace, unique:=True
.UsedRange.SpecialCells(xlCellTypeVisible).Copy _
Destination:=ActiveSheet.Range("A1")
.ShowAllData
End With
Application.CutCopyMode = False
'Release memory
Set RUniqueCells = Nothing
End Sub

My question is this:
How do I modify the macro routine so that it searches the active sheet and not just sheet1.
Also, is it possible to modify the macro so that it "asks" which column to search for duplicates in.
The current macro defaults to searching in column A only.
thanks

Posted by Mark W. on July 18, 2001 10:56 AM

You can also use ASAP Utilities' freeware supported
command Range | Empty duplicates in selection

This utility is available for download at
www.asap-utilities.com

Posted by unstuck2 on July 18, 2001 12:22 PM

Thanks for hte response.
The workbook will be used by many people thru network installed Excel in the NT environment.
I am sure our administrator will not allow installation of add-on utilities (if that's what "ASAP Utilities" are!).
Even official microsoft stuff takes months (if ever) before filtering down to us.
Is there a way to accomplish this within Excel?



Posted by Mark W. on July 18, 2001 12:30 PM

There's always Advanced AutoFilter using the
"Unique records only" option.