Sub Trier()
Set mondico = CreateObject("Scripting.Dictionary")
Set p1 = Application.InputBox("Plage contenant les valeurs à trier : ", , , , , , , 8)
Set p2 = Application.InputBox("Plage contenant les villes à ne pas considérer : ", , , , , , , 8)
Set p3 = Application.InputBox("Cellule de destination : ", , , , , , , 8)
For Each c In p1
Nb = Application.WorksheetFunction.CountIf(p2, c.Value)
If c.Value <> "" And Nb = 0 Then
mondico.Item(c.Value) = c.Value
End If
Next c
temp = mondico.Items
Call tri(temp, LBound(temp), UBound(temp))
p3.Resize(mondico.Count, 1) = Application.Transpose(temp)
End Sub
Sub tri(a, gauc, droi) ' Quick sort
ref = a((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(g) < ref: g = g + 1: Loop
Do While ref < a(d): d = d - 1: Loop
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call tri(a, g, droi)
If gauc < d Then Call tri(a, gauc, d)
End Sub