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
| Option Base 1
Private Sub UserForm_Initialize()
Dim LastLig As Long, j As Long
Dim i As Byte
Dim ColCrit
ColCrit = Array(2, 3, 4, 6, 7, 8, 9, 13, 15, 18, 19, 20, 23, 26, 27)
With Sheets("bras")
.AutoFilterMode = False 'on enlève le filtre automatique de la page
LastLig = .Cells(.Rows.Count, 1).End(xlUp).Row 'dernière ligne remplie de la colonne 1
For i = 1 To UBound(ColCrit) 'on parcourt les 15 combobox nommées ComboBox1, ComboBox2...ComboBox5
For j = 2 To LastLig
Me.Controls("ComboBox" & i).Value = .Cells(j, ColCrit(i)).Value
If Me.Controls("ComboBox" & i).ListIndex = -1 Then Me.Controls("ComboBox" & i).AddItem .Cells(j, ColCrit(i)).Value
Me.Controls("ComboBox" & i).ListIndex = -1
Next j
Next i
End With
End Sub
Private Sub CommandButton1_Click()
Dim LastLig As Long
Dim i As Byte
Dim ColCrit
ColCrit = Array(2, 3, 4, 6, 7, 8, 9, 13, 15, 18, 19, 20, 23, 26, 27)
With Sheets("bras")
.AutoFilterMode = False 'on enlève le filtre automatique de la page
LastLig = .Cells(.Rows.Count, 1).End(xlUp).Row 'dernière ligne remplie de la colonne 1
With .Range("A1:AA" & LastLig)
For i = 1 To UBound(ColCrit) 'on parcourt les 5 combobox nommées ComboBox1, ComboBox2...ComboBox5
If Me.Controls("ComboBox" & i).ListIndex > -1 Then .AutoFilter Field:=ColCrit(i), Criteria1:=Me.Controls("ComboBox" & i).Value
Next i
End With
End With
Unload Me
End Sub |