Filtrer Listbox à l'aide d'une saisie dans Textbox
Bonjour à tous,
Je souhaite trouver le moyen de filtrer le contenu de ma listbox en fonction de la saisie de ma textbox (des dates seront uniquement saisies JJ/MM/AAAA)
J'y arrive avec des boutons d'option, mais pas avec une textbox.
J'appel une fonction pour charger ma listbox qui fonctionne parfaitement, mais au niveau du filtre (saisie textbox), du coup je coince :
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| Function P3()
'la condition du filtre devrait être placé ici, pour donner un truc comme ça :
If P3Textbox.Value <> "" Then
lefiltre = 'Serait une date
End If
'alimente la listbox
Dim col As Byte
Dim lign As Long, drlig As Long
If P3Cbformation = "" Then Exit Function
P3Listbox.Clear
With Workbooks("FORMATIONS").Worksheets("formations")
drlig = Workbooks("FORMATIONS").Worksheets("formations").range("A" & Workbooks("FORMATIONS").Worksheets("formations").Rows.Count).End(xlUp).Row
If lefiltre = P3Textbox.Value Then
For lign = 1 To drlig
If .Cells(lign, 6) = P3Cbformation Then
P3Listbox.AddItem .Cells(lign, 1)
For col = 1 To 9
If col = 8 Then
P3Listbox.List(P3Listbox.ListCount - 1, col) = .Cells(lign, 36)
Else
P3Listbox.List(P3Listbox.ListCount - 1, col) = .Cells(lign, col + 1)
End If
Next col
End If
Next lign
Else
For lign = 1 To drlig
If .Cells(lign, 6) = P3Cbformation And .Cells(lign, 33) = lefiltre Then '(Mes dates sont insérées dans la colonne 33 de ma feuille)
P3Listbox.AddItem .Cells(lign, 1)
For col = 1 To 9
If col = 8 Then
P3Listbox.List(P3Listbox.ListCount - 1, col) = .Cells(lign, 36)
Else
P3Listbox.List(P3Listbox.ListCount - 1, col) = .Cells(lign, col + 1)
End If
Next col
End If
Next lign
End If
End With
End Function |
Merci beaucoup