XL 2019 Importer des données de colonne spécifiques dans combobox

Dadi147

XLDnaute Occasionnel
Bonjour. S’il vous plaît aider à activer le code de la zone de liste déroulante userform pour récupérer des données à partir de plusieurs colonnes avec la possibilité de rechercher à l’intérieur de la zone de texte Je peux maintenant rechercher avec un seul élément Comment puis-je activer 4 ou 5 commobooks de la même manière

11.PNG


VB:
Dim f, bd()
Private Sub UserForm_Initialize()
  Set f = Sheets("data")
  f.Activate
  bd = f.Range("a2:a" & [a65000].End(xlUp).Row).Value
   Set d1 = CreateObject("scripting.dictionary")
   For i = 1 To UBound(bd)
     If bd(i, 1) <> "" Then d1(bd(i, 1)) = ""
   Next i
   a = d1.keys
   Me.ComboBox1.List = a
   Me.ComboBox1.SetFocus
End Sub
Private Sub ComboBox1_Change()
     Set d1 = CreateObject("scripting.dictionary")
     clé = UCase(Me.ComboBox1) & "*"
     Dim Tbl()
     n = 0: ncol = UBound(bd, 2)
     For i = LBound(bd) To UBound(bd)
       If UCase(bd(i, 1)) Like clé Then
         n = n + 1: ReDim Preserve Tbl(1 To ncol, 1 To n)
         For k = 1 To ncol: Tbl(k, n) = bd(i, k): Next
         If bd(i, 1) <> "" Then d1(bd(i, 1)) = ""
       End If
      Next i
      a = d1.keys
      Me.ComboBox1.List = a
      Me.ComboBox1.DropDown
      Me.TextBox1.Value = Me.ComboBox1.Value
End Sub
Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
  Set d1 = CreateObject("scripting.dictionary")
  For i = 1 To UBound(bd)
    If bd(i, 1) <> "" Then d1(bd(i, 1)) = ""
  Next i
  a = d1.keys
 
  Me.ComboBox1.List = a
  Me.ComboBox1.DropDown
  Me.TextBox1.Value = Me.ComboBox1.Value
End Sub
 

Pièces jointes

  • ListBoxMultiColIntuitifCombobox.xlsm
    34.7 KB · Affichages: 8

Discussions similaires

Réponses
11
Affichages
284

Statistiques des forums

Discussions
312 163
Messages
2 085 859
Membres
103 005
dernier inscrit
gilles.hery