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 50 51
| Option Compare Text
Dim TBlBD(), Tbl(), ColRechCbx
Private Sub UserForm_Initialize()
TBlBD = [tableau1].Value ' pour rapidité
Me.ListBox1.List = TBlBD
Me.ListBox1.ColumnCount = [tableau1].Columns.Count
Me.ListBox1.ColumnWidths = "20;70;50;30;0;50;50;50;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0"
'------------------------ Alimentation ComboBox
ColRechCbx = [Tableau1[classe]].Column
Set d = CreateObject("scripting.dictionary")
d("*") = ""
For i = 1 To UBound(TBlBD)
d(TBlBD(i, ColRechCbx)) = ""
Next i
temp = d.keys
'Tri temp, LBound(temp), UBound(temp)
Me.ComboBox1.List = temp
Me.ComboBox1 = "*"
End Sub
Private Sub ComboBox1_click()
NbLignes = Application.CountIf([Tableau1[Classe]], Me.ComboBox1)
clé = Me.ComboBox1: n = 0
ReDim Tbl(1 To NbLignes, 1 To UBound(TBlBD, 2))
For i = 1 To UBound(TBlBD)
If TBlBD(i, ColRechCbx) Like clé Then
n = n + 1
For k = 1 To UBound(TBlBD, 2): Tbl(n, k) = TBlBD(i, k): Next k
End If
Next i
Me.TextBoxRech = ""
If n > 0 Then Me.ListBox1.List = Tbl Else Me.ListBox1.Clear
End Sub
Private Sub TextBoxRech_Change()
ColRechTextbox = 2
Dim b()
If Me.TextBoxRech <> "" Then
tmp = Me.TextBoxRech & "*"
n = 0
For i = 1 To UBound(Tbl)
If Tbl(i, ColRechTextbox) Like tmp Then
n = n + 1: ReDim Preserve b(1 To UBound(Tbl, 2), 1 To n)
For k = 1 To UBound(Tbl, 2): b(k, n) = Tbl(i, k): Next k
End If
Next i
If n > 0 Then Me.ListBox1.Column = b Else Me.ListBox1.Clear
Else
Me.ListBox1.List = Tbl
End If
End Sub |
Partager