2 colonnes dans Listbox a recherche par criteres

Bonjour a tous,

J'aurais besoin d'un coup de main pour afficher 2 colonnes dans ma ChoixListbox8, colonnes 17 et 18 puis effectuer la recherche incrémentale par critères a sélectionner.

En vous remerciant par avance de votre soutien

a+

13test-2-3.xlsm (71.37 Ko)

Bonjour Benji77

Et si dans Userform_Initialize

tu mettais

For i = LBound(TblBD) To UBound(TblBD)
d(CStr(TblBD(i, 17)) + "!" + CStr(TblBD(i, 18))) = ""
Next i
Me.ChoixListBox8.List = liste_triée_sans_doublons(d.keys)

Au lieu de

For i = LBound(TblBD) To UBound(TblBD)
d(TblBD(i, 17)) = ""
Next i
Me.ChoixListBox8.List = liste_triée_sans_doublons(d.keys)

Pour la saisie incrémentale je ne vois pas encore comment faire

Bonjour Scraper,

Merci de ton soutien, je vais essayer ...

Je te tiens au courant,

A+

J'ai essaye cela me convient parfaitement, MERCI !

Il ne reste plus qu'a trouver pour la recherche incrémentale ...

Je l'ai mis sous cette forme pour plus de lisibilité dans ChoixListbox8:

For i = LBound(TblBD) To UBound(TblBD)
d(CStr(TblBD(i, 17)) + " - " + CStr(TblBD(i, 18))) = ""
Next i
Me.ChoixListBox8.List = liste_triée_sans_doublons(d.keys)
    
Sub Affiche()
Dim i As Long
Dim j As Byte, k As Byte
Dim dchoisis(1 To 9)

  Set dchoisis1 = CreateObject("Scripting.Dictionary")
  For i = 0 To Me.ChoixListBox1.ListCount - 1
    If Me.ChoixListBox1.Selected(i) Then dchoisis1(Me.ChoixListBox1.List(i, 0)) = ""
  Next i
  Set dchoisis2 = CreateObject("Scripting.Dictionary")
  For i = 0 To Me.ChoixListBox2.ListCount - 1
    If Me.ChoixListBox2.Selected(i) Then dchoisis2(Me.ChoixListBox2.List(i, 0)) = ""
  Next i
  Set dchoisis3 = CreateObject("Scripting.Dictionary")
  For i = 0 To Me.ChoixListBox3.ListCount - 1
    If Me.ChoixListBox3.Selected(i) Then dchoisis3(Me.ChoixListBox3.List(i, 0)) = ""
  Next i
  Set dchoisis4 = CreateObject("Scripting.Dictionary")
  For i = 0 To Me.ChoixListBox4.ListCount - 1
    If Me.ChoixListBox4.Selected(i) Then dchoisis4(Me.ChoixListBox4.List(i, 0)) = ""
  Next i
 Set dchoisis5 = CreateObject("Scripting.Dictionary")
  For i = 0 To Me.ChoixListBox5.ListCount - 1
    If Me.ChoixListBox5.Selected(i) Then dchoisis5(Me.ChoixListBox5.List(i, 0)) = ""
  Next i
  Set dchoisis6 = CreateObject("Scripting.Dictionary")
  For i = 0 To Me.ChoixListBox6.ListCount - 1
    If Me.ChoixListBox6.Selected(i) Then dchoisis6(Me.ChoixListBox6.List(i, 0)) = ""
  Next i
  Set dchoisis7 = CreateObject("Scripting.Dictionary")
  For i = 0 To Me.ChoixListBox7.ListCount - 1
    If Me.ChoixListBox7.Selected(i) Then dchoisis7(Me.ChoixListBox7.List(i, 0)) = ""
  Next i
   Set dchoisis8 = CreateObject("Scripting.Dictionary")
  For i = 0 To Me.ChoixListBox8.ListCount - 1
    If Me.ChoixListBox8.Selected(i) Then dchoisis8(Me.ChoixListBox8.List(i, 0)) = ""
  Next i

  n = 0: Dim Liste()
  For i = LBound(TblBD) To UBound(TblBD)
     tmp = TblBD(i, 1)
     tmp2 = TblBD(i, 2)
     tmp3 = TblBD(i, 3)
     tmp4 = TblBD(i, 4)
     tmp5 = TblBD(i, 5)
     tmp6 = TblBD(i, 6)
     tmp7 = TblBD(i, 7)
     tmp8 = TblBD(i, 17) + TblBD(i, 18)

     If (dchoisis1.Exists(tmp) Or dchoisis1.Count = 0) _
        And (dchoisis2.Exists(tmp2) Or dchoisis2.Count = 0) _
          And (dchoisis3.Exists(tmp3) Or dchoisis3.Count = 0) _
            And (dchoisis4.Exists(tmp4) Or dchoisis4.Count = 0) _
              And (dchoisis5.Exists(tmp5) Or dchoisis5.Count = 0) _
                And (dchoisis6.Exists(tmp6) Or dchoisis6.Count = 0) _
                  And (dchoisis7.Exists(tmp7) Or dchoisis7.Count = 0) _
                    And (dchoisis8.Exists(tmp8) Or dchoisis8.Count = 0) Then

         n = n + 1
         ReDim Preserve Liste(1 To NbCol + 1, 1 To n)
         For k = 1 To NbCol + 1
            Liste(k, n) = TblBD(i, k)
         Next k
     End If
  Next i
  If n > 0 Then Me.ListBox1.Column = Liste Else Me.ListBox1.Clear
End Sub

J'ai rajouter ceci dans le "Sub Affiche"mais cela filtre sans résultat apparent....

tmp8 = TblBD(i, 17) + TblBD(i, 18)

A+

Benji77, ce ne serait pas que tu oublies quelque chose : le tiret
tmp8 = TblBD(i, 17) + " - " + TblBD(i, 18)

J'avais pas oublie, j'avais Hélas un bug quand je sélectionne un critère dans la Listbox8, j'ai du l'enlever .... j'essaye de trouver

Merci pour ta bienveillance !

a+

Merci

Rechercher des sujets similaires à "colonnes listbox recherche criteres"