Sub MajAvecTriTableauVBA()
Dim t, tablo, x$, i&, y$, z$, n&
t = Timer
Application.ScreenUpdating = False
[D:E].Copy [G1] 'copier-coller
[G:H].Sort [G1], xlAscending, [H1], , xlAscending, Header:=xlYes 'tri sur 2 colonnes
tablo = [G1].CurrentRegion 'matrice, plus rapide
x = tablo(1, 1) & tablo(1, 2)
For i = 2 To UBound(tablo)
y = tablo(i, 1): z = tablo(i, 2)
If x <> y & z Then
n = n + 1
tablo(n, 1) = y: tablo(n, 2) = z
End If
x = y & z
Next
'---restitution---
With [G2]
If n Then .Resize(n, 2) = tablo
.Offset(n).Resize(Rows.Count - n - .Row + 1, 2).ClearContents 'RAZ en dessous
End With
MsgBox Format(Timer - t, "0.0\ sec.")
End Sub