Hello hpaum99,
This macro is not effected by the 8192 cell limit imposed by the SpecialCells method. A button has been added to the sheet to run the macro.
Sub DeleteDuplicates()
Dim Data() As Variant
Dim I As Long, N As Long
Dim Rng As Range
Dim RngEnd As Range
Dim SN As Object
Dim Wks As Worksheet
Set Wks = Worksheets("Sheet2")
Set Rng = Wks.Range("A3:B3")
Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
Set Rng = IIf(RngEnd.Row < RngRow, Rng, Wks.Range(Rng, RngEnd))
Rng.Sort _
Key1:=Rng.Item(1).Offset(-1, 0), Order1:=xlAscending, _
Key2:=Rng.Item(2).Offset(-1, 0), Order2:=xlDescending, _
Header:=xlYes, MatchCase:=False, Orientation:=xlTopToBottom
ReDim Data(1 To Rng.Rows.Count, 1 To 2)
Set SN = CreateObject("Scripting.Dictionary")
SN.CompareMode = vbTextCompare
Application.ScreenUpdating = False
CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual
For I = 1 To Rng.Rows.Count
Key = Rng.Item(I, 1)
If Key <> "" Then
If Not SN.Exists(Key) Then
SN.Add Key, Rng.Item(I, 2)
N = N + 1
Data(N, 1) = Rng.Item(I, 1)
Data(N, 2) = Rng.Item(1, 2)
Else
Rng.Item(I, 1).Resize(1, 2).Value = ""
End If
End If
Next I
Rng.Value = Data()
Application.Calculation = CalcMode
Application.ScreenUpdating = False
End Sub
Bookmarks