Tx John...Now I understand...
We all get same results...
Sub J3v16()
Dim Num, NumChk, Data, Tm As Double, Dict As Object, Fnd As Range, i As Long
Set Dict = CreateObject("Scripting.Dictionary")
Tm = Timer
With Range("L1:R" & Cells(Rows.Count, 12).End(xlUp).Row)
Num = Join(Application.Transpose(Application.Transpose(.Rows(1))), "")
Dict.Add Num, ""
Data = .Value
For i = 2 To UBound(Data)
NumChk = Data(i, 1) & Data(i, 2) & Data(i, 3) & Data(i, 4) & Data(i, 5) & Data(i, 6) & Data(i, 7)
'! Above snippet as Join is .20s longer....
If Not Dict.exists(NumChk) Then Data(i, 7) = ""
Next i
.Value = Data
.Sort .Columns(7), xlAscending, , , , , , xlYes
Set Fnd = .Columns(7).Find("", , xlValues, xlWhole)
.Rows(Fnd.Row & ":" & .Rows.Count).Clear
End With
Debug.Print Format(Timer - Tm, "0.00") '! 0.20s
End Sub
This is a little faster...
Sub J3v16()
Dim Num, Data, Temp, Tm As Double
Tm = Timer
With Range("L1:R" & Cells(Rows.Count, 12).End(xlUp).Row).Resize(, 8)
.Columns(8).Formula = "=L1&M1&N1&O1&P1&Q1&R1"
Num = Join(Application.Transpose(Application.Transpose(.Cells(1).Resize(, 7))), "")
Data = Filter(Evaluate("Transpose(If(" & .Columns(8).Address & "=""" & Num & """,row(1:" & .Rows.Count & ")))"), False, 0)
If UBound(Data) > -1 Then
Temp = Application.Index(.Value, Application.Transpose(Data), Array(1, 2, 3, 4, 5, 6, 7))
.Clear
.Resize(IIf(UBound(Data) = 0, 1, UBound(Temp)), 7) = Temp
End If
End With
Debug.Print Format(Timer - Tm, "0.00") '! 0.13s
End Sub
@John...Would like to see how these perform on your PC...
Bookmarks