MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Deleting Dups

Posted by Tricia on January 21, 2002 8:38 AM

I have the following macro to delete duplicates. I sort first, of course. The problem is, I have to know the maximum # of times a one of the values in the elected area is duplicated to know how many times to loop it. Is there a better way? Thanks :-)

Sub DeleteDups()
Application.ScreenUpdating = False
For uY = 1 To 6 'Spin through 6 times
For Each Cell In Selection
If Cell.Value = Cell.Offset(1, 0).Value Then
Cell.EntireRow.DELETE (xlShiftUp)
End If
Next Cell
End Sub

Posted by Juan Pablo G. on January 21, 2002 8:40 AM

Record a macro using Advanced Filter, and check "Unique Entries Only", and copy to a new location (If you want, i would). Then, delete the original column.

Juan Pablo G.