Dim var
Private Sub ListBox1_Click()
Dim Valeur As String
Dim Tableau()
Dim x As Long
Dim i&
ListBox2.Clear
ListBox3.Clear
ListBox4.Clear
ListBox5.Clear
ListBox6.Clear
ListBox7.Clear
If ListBox1 = -1 Then Exit Sub
var = Sheets(MA_BD).[a1].CurrentRegion
Valeur = ListBox1.Value
For i& = 2 To UBound(var, 1)
If var(i&, 1) = Valeur Then
ReDim Preserve Tableau(0, x)
Tableau(0, x) = var(i&, 3)
x = x + 1
End If
Next i&
ListBox2.List = Application.WorksheetFunction.Transpose(Tableau)
End Sub
Private Sub ListBox2_Click()
Dim myTab(1 To 4) As structMyTab
Dim NumLig&
Dim i&
Dim cpt&
ListBox3.Clear
ListBox4.Clear
ListBox5.Clear
ListBox6.Clear
ListBox7.Clear
If ListBox2 = -1 Then Exit Sub
For i& = 2 To UBound(var, 1)
If var(i&, 1) = ListBox1 And var(i&, 3) = ListBox2 Then
NumLig& = i&
Exit For
End If
Next i&
ListBox3.AddItem (var(NumLig&, 2))
For i& = 5 To UBound(var, 2) Step 4
cpt& = cpt& + 1
myTab(1).Tbl(1, cpt&) = var(NumLig&, i&)
myTab(2).Tbl(1, cpt&) = var(NumLig&, i& + 1)
myTab(3).Tbl(1, cpt&) = var(NumLig&, i& + 2)
myTab(4).Tbl(1, cpt&) = var(NumLig&, i& + 3)
Next i&
ListBox4.List() = myTab(1).Tbl
ListBox5.List() = myTab(2).Tbl
ListBox6.List() = myTab(3).Tbl
ListBox7.List() = myTab(4).Tbl
End Sub
Private Sub UserForm_Activate()
Dim Cell As Range
Dim Unique As New Collection
Dim Valeur As Range
Dim i As Long
i = Feuil3.Range("b65536").End(xlUp).Row
On Error Resume Next
For Each Cell In Feuil3.Range("a2:a" & i)
If Cell <> "" Then
Unique.Add Cell, CStr(Cell)
End If
Next Cell
On Error GoTo 0
For Each Valeur In Unique
UserForm3.ListBox1.AddItem Valeur
Next Valeur
ListBox2.ColumnCount = 1
ListBox2.ColumnWidths = "100"
ListBox3.ColumnCount = 1
ListBox3.ColumnWidths = "100"
ListBox4.ColumnCount = 5
ListBox4.ColumnWidths = "100;100;100;100;100"
ListBox5.ColumnCount = 5
ListBox5.ColumnWidths = "100;100;100;100;100"
ListBox6.ColumnCount = 5
ListBox6.ColumnWidths = "100;100;100;100;100"
ListBox7.ColumnCount = 5
ListBox7.ColumnWidths = "100;100;100;100;100"
End Sub