Deleting dupes


Posted by Jessica on June 20, 2000 2:53 PM

This is probably easy, but I haven't figured it out yet. I import data from an ASCII file when the info shows up in Excel, there are 2-3 lines of the same information, for 300+ invoices. I've been going through and deleting the dupes, but I about go crazy going through hundreds and hundreds of entries!

What's the easiest way to delete dupes? The duplicate lines are exactly the same. Do I need to do a macro? yikes..

Thanks!



Posted by Ryan on June 20, 0100 6:11 PM

Hey Jessica,
This was an easy one, just copy this code and run it. You might have to modify it for your needs. I have it so it goes down column A and if the there are two cells together that are the same it will delete the second one and move all the other ones up. I can do it for more then two cells but i thought it would be safer to do it just one at a time. So if you have two are three together, just run the macro two or three times, it only takes a second. Hope you like it, let me know. Ryan

Sub RemoveDupes()

Dim Entries As Integer

On Error Resume Next
Application.ScreenUpdating = False
Entries = Application.WorksheetFunction.CountA(Range("A:A"))
For X = 1 To Entries
If Cells(X, 1).Value = Cells(X + 1, 1).Value Then _
Rows(X + 1 & ":" & X + 1).Delete Shift:=xlUp
Next X
Application.ScreenUpdating = True
End Sub