I am using the following macro to delete entire duplicate lines. The duplicate are found in column Q. I have data all the way to column AH.
However, it is extremely slow and can take more than an hour when I sometimes have close to 30,000 rows. Is there a way I can speed this up?
Code:
Sub RemoveALLDuplicates()
With Application
.EnableEvents = False
.ScreenUpdating = False
PrevCalc = .Calculation
.Calculation = xlCalculationManual
End With
'Application.ScreenUpdating = False
Dim r As Range, txt As String
With CreateObject("Scripting.Dictionary")
Again:
For Each r In Range("Q1", Range("Q" & Rows.Count).End(xlUp))
If Not .exists(r.Value) Then
.Add r.Value, Nothing
Else
txt = txt & "," & r.Address(0, 0)
If Len(txt) > 245 Then
Intersect(Range(Mid(txt, 2)).EntireRow, Columns("B:IV")).Delete
.RemoveAll
txt = Empty: GoTo Again
End If
End If
Next
End With
If Len(txt) Then Intersect(Range(Mid(txt, 2)).EntireRow, Columns("B:IV")).Delete
'Application.ScreenUpdating = True
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = PrevCalc
End With
End Sub
However, it is extremely slow and can take more than an hour when I sometimes have close to 30,000 rows. Is there a way I can speed this up?