1 pièce(s) jointe(s)
VBA ListBox avec recherche multicritéres
Bonjour,
J'ai un tableau avec une liste de pièces (1000 pièces). Le tableau à une seule colonne avec tous les détails des pièces.
A la sélection d'une cellule la Userform s'affiche, je fais ma première recherche via la TextBox1 avec le critére "attac", la liste se réduit, jusque la pas de problème.
J'aimerai pouvoir affiner la rechreche avec le texte afficher via la TextBox2 avec le critére "EM" et pouvoir encore affiner la rechreche avec le texte afficher, via la TextBox3 avec le critére "3"
Voici le code et une image de l'UserForm
Merci pour votre aide et excellent week-end
Philippe
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Dim a
Private Sub UserForm_Initialize()
a = [Liste_Pieces].Value
Me.ListBox1.List = a
Me.Search_dans_tous_les_mots.SetFocus 'Place le curseur dans la textbox
End Sub
Private Sub Search_dans_tous_les_mots_Change()
Set D1 = CreateObject("Scripting.Dictionary")
Me.ListBox1.Clear
tmp = "*" & UCase(Me.Search_dans_tous_les_mots) & "*"
For Each C In a
If UCase(C) Like tmp Then D1(C) = ""
Next C
Me.ListBox1.List = D1.keys
End Sub
'Private Sub Search_premiere_lettre_change()
' Set D1 = CreateObject("Scripting.Dictionary")
' Me.ListBox1.Clear
' tmp = UCase(Me.Search_premiere_lettre) & "*"
' For Each C In a
' If UCase(C) Like tmp Then D1(C) = ""
' Next C
' Me.ListBox1.List = D1.keys
'End Sub
Private Sub ListBox1_Click()
ActiveCell = Me.ListBox1
Unload Me
End Sub |