Function TriFiltre(t, liste$, colref%, coltri%, colrestit%)
Dim i&, n&, a(), b()
t = t 'matrice, plus rapide
For i = 1 To UBound(t)
If InStr(liste, Right(t(i, colref), 1)) Then
n = n + 1
ReDim Preserve a(1 To n): ReDim Preserve b(1 To n)
a(n) = t(i, coltri)
b(n) = t(i, colrestit)
End If
Next
tri a, b, 1, UBound(a)
TriFiltre = b 'vecteur ligne
End Function
Sub tri(a, b, gauc, droi) ' Quick sort (2 colonnes triées)
Dim ref, g, d, temp
ref = a((gauc + droi) \ 2) & b((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(g) & b(g) < ref: g = g + 1: Loop
Do While ref < a(d) & b(d): d = d - 1: Loop
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
temp = b(g): b(g) = b(d): b(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call tri(a, b, g, droi)
If gauc < d Then Call tri(a, b, gauc, d)
End Sub