shahin
Active Member
I've written a macro to remove duplicate values by deleting the entire row. The macro is supposed to compare the value of Range A1 to any of the Range underneath within the same column to be sure that they are not the same. If it is then it will delete the entire row in which duplicate value is found. My macro can do that but I need to run the macro twice to get the whole thing done because after first run i can still see some duplicates. However, when i run it twice or thrice, it can shake off all duplicate values. One more thing: it takes almost 3 minutes to shake off 2500 duplicates out of 6000. That means it works slowly as well. What change should i make in my macro to do the whole stuff in a single run and within fewer times possible?
Here is what I was trying with:
Here is what I was trying with:
Code:
Sub Dup_removal()
Application.ScreenUpdating = False
Dim i As Long
Dim j As Long
i = 2
Do Until Cells(i, 1).Value = ""
j = i + 1
Do Until Cells(j, 1).Value = ""
If Cells(i, 1).Value = Cells(j, 1).Value Then
Cells(j, 1).Select
Selection.EntireRow.Delete
End If
j = j + 1
Loop
i = i + 1
Loop
Application.ScreenUpdating = True
End Sub