Link to home
Start Free TrialLog in
Avatar of entrerri
entrerri

asked on

Deleting Duplicate Entries

This one is actually just a way to clean up code.  I'm using the following code to delete duplicate entries (the entries are sorted first).  Anyone have a cleaner method, or something that will run faster?

Sub remove_dups()
Do
    If IsEmpty(Selection) Then Exit Do
    If Selection = ActiveCell.Offset(1, 0) Then
        ActiveCell.Offset(1, 0).EntireRow.Delete
        ActiveCell.Offset(-1, 0).Select
    End If
    ActiveCell.Offset(1, 0).Select
Loop
End Sub
SOLUTION
Avatar of Anne Troy
Anne Troy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh...I'm just bored today, Matt. :)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nothing wrong with that, Anne :)
Whoa! I just noticed I passed you in total points! Must have happened at some point today. Then again you used to spend a lot of your time here NOT answering questions, but instead cleaning up others mistakes :P

enterri,
If you want to be able to choose the column/range at runtime, change the
 Set CheckRange = ....
line to
 On Error Resume Next
 Set CheckRange = Application.InputBox(Prompt:="Please select column to delete " & _
  "duplicates", Title:="Choose column/range", Default:="$A:$A", Type:=8)
 If CheckRange Is Nothing Then Exit Sub
 On Error GoTo 0

And the macro will prompt you at runtime to choose the column(s).  Just an afterthought
Matt
Avatar of entrerri
entrerri

ASKER

Oh Harish you win this one big time, though great thanks to the rest of you.  Advanced Filter is simple quick and directly to the point, however, lots of help on code from all.  Thanks Guys
Harish...I sent you an email at gmail. :)
Thanks
Dreamboat (Anne), I am checking...
Thanks a bunch, entrerri. I haven't gotten any points here at EE in ages. Hee hee...