Bonjour,
Dans le code ci-dessous j'affiche une ListBox à l’initialisation du formulaire.
Quand je sélectionne un Item dans le ComboBox, je filtre la ListBox.
Par contre je n'arrive pas à revenir aux données à l'initialisation lorsque je ne sélectionne rien dans le ComboBox.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Dim f, bd Option Compare Text Private Sub UserForm_Initialize() Set f = Sheets("GARDE_JOUR") Set d = CreateObject("Scripting.Dictionary") bd = f.Range("A2:E" & f.[A65000].End(xlUp).Row).Value Tri bd, LBound(bd), UBound(bd), 3 ' tri Me.ListBox1.List = bd For I = LBound(bd) To UBound(bd) d(bd(I, 3)) = "" Next I Me.ComboBox1.List = d.keys Me.ListBox1.ColumnCount = 5 Me.ListBox1.ColumnWidths = "80;30;50;50;50" 'MsgBox ListBox1.ListCount Tri_ListBox End Sub Private Sub ComboBox1_click() site = Me.ComboBox1: n = 0 Dim Tbl() For I = 1 To UBound(bd) If bd(I, 3) = site Then n = n + 1: ReDim Preserve Tbl(1 To UBound(bd, 2), 1 To n) For k = 1 To UBound(bd, 2): Tbl(k, n) = bd(I, k): Next k End If Next I Me.ListBox1.Column = Tbl Tri_ListBox End Sub
Partager