Userform filtres multi-critères sans doublon par ordre A-Z | Adaptation

Bonjour,

J'aimerais ajuster le code ci-dessous de mon Userform qui récupère les critères de filtrage de la colonne C à partir de C17 sans doublon puis triés par ordre A-Z pour choix dans une ComboBox.

J'aimerais effectuer la même manipulation pour 3 autres colonnes filtrées

Fonctionnement actuel : le Userform apparaît en cliquant sur un bouton FILTRAGE puis laisse choisir dans des listes déroulante le critère de filtrage désiré pour chacun des 4 filtres. Les critères pour les autres 3 filtres sont actuellement définis dans les paramètres RowSource des ComboBox par un Range sur une autre feuille et donc pas définis dynamiquement.

Private Sub UserForm_Initialize()

'FILTRAGE COLONNE EQP (PAR ORDRE ALPHABETIQUE)

Set f = Sheets("Feuil1")
  Set MonDico = CreateObject("Scripting.Dictionary")
  a = f.Range("C17:C" & f.[C65000].End(xlUp).Row)  ' tableau a(n,1) pour rapidité
  For i = LBound(a) To UBound(a)
   If a(i, 1) <> "" Then MonDico(a(i, 1)) = ""
  Next i
  Me.ComboBox4.List = MonDico.keys
  '--avec tri
  temp = MonDico.keys
  Call Tri(temp, LBound(temp), UBound(temp))
  Me.ComboBox4.List = 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

La dernière pièce jointe de @gmb dans le lien ci-dessous illustre à 100% ce que je cherche à faire mais je ne saurais trouver de compromis entre le code ci-dessus et le code utilisé par @gmb

https:// forum.excel-pratique.com/excel/userform-filtre-multi-criteres-80485#p464069

(je ne peux pas poster de liens, merci de supprimer l'espace entre "/" et "forum")
Je me suis inspiré des infos trouvées sur ce thread ainsi que sur le blog de boisgontierj

Toute aide est la bienvenue

Merci d'avance

2e sujet où je réponds à ma propre question... Je vais commencer à me sentir intelligemment idiot (ou idiotement intelligent)

En espérant que ça serve à d'autres, voici le code adapté pour 3 filtres :

(Dans Userform Initialize : changer de nom les variables a , le range B5:B et [B65000], temp, mondico1, la fonction Tri, le nom de la ComboBox

Dans la fonction appelée : la variable a, temp, la fonction Tri)

Private Sub UserForm_Initialize()

'FILTRAGE COLONNE EPT (PAR ORDRE ALPHABETIQUE)

Set f = Sheets("Feuil1")
  Set mondico1 = CreateObject("Scripting.Dictionary")
  a = f.Range("B5:B" & f.[B65000].End(xlUp).Row)   ' tableau a(n,1) pour rapidité
  For i = LBound(a) To UBound(a)
    If a(i, 1) <> "" Then mondico1(a(i, 1)) = ""
  Next i
  '--avec tri
  temp = mondico1.keys
  Call Tri(temp, LBound(temp), UBound(temp))
  Me.ComboBox1.List = temp

  Set mondico2 = CreateObject("Scripting.Dictionary")
  b = f.Range("C5:C" & f.[C65000].End(xlUp).Row)   ' tableau b(n,1) pour rapidité
  For i = LBound(b) To UBound(b)
    If b(i, 1) <> "" Then mondico2(b(i, 1)) = ""
  Next i
  '--avec tri
  temp1 = mondico2.keys
  Call Tri1(temp1, LBound(temp1), UBound(temp1))
  Me.ComboBox2.List = temp1

  Set mondico3 = CreateObject("Scripting.Dictionary")
  c = f.Range("E5:E" & f.[E65000].End(xlUp).Row)   ' tableau c(n,1) pour rapidité
  For i = LBound(c) To UBound(c)
    If c(i, 1) <> "" Then mondico3(c(i, 1)) = ""
  Next i
  '--avec tri
  temp2 = mondico3.keys
  Call Tri2(temp2, LBound(temp2), UBound(temp2))
  Me.ComboBox3.List = temp2

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

Sub Tri1(b, gauc, droi) ' Quick sort
  ref = b((gauc + droi) \ 2)
  g = gauc: d = droi
  Do
     Do While b(g) < ref: g = g + 1: Loop
     Do While ref < b(d): d = d - 1: Loop
     If g <= d Then
        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 Tri1(b, g, droi)
   If gauc < d Then Call Tri1(b, gauc, d)
End Sub

Sub Tri2(c, gauc, droi) ' Quick sort
  ref = c((gauc + droi) \ 2)
  g = gauc: d = droi
  Do
     Do While c(g) < ref: g = g + 1: Loop
     Do While ref < c(d): d = d - 1: Loop
     If g <= d Then
        temp = c(g): c(g) = c(d): c(d) = temp
        g = g + 1: d = d - 1
     End If
   Loop While g <= d
   If g < droi Then Call Tri2(c, g, droi)
   If gauc < d Then Call Tri2(c, gauc, d)
End Sub
Rechercher des sujets similaires à "userform filtres multi criteres doublon ordre adaptation"