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
| Private Sub UserForm_Initialize() 'Mise en forme de USF avec récupération des données sur la BDD
Dim LastLig As Long
Dim j As Long
Dim i As Byte
Dim n As Long
Dim ColCrit
Dim x As Integer, y As Integer
ColCrit = Array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 22, 23) ' n° de colonnes choisies pour le filtrage
With Sheets("bras")
.AutoFilterMode = False
LastLig = .Cells(.Rows.Count, 4).End(xlUp).Row
For i = 1 To UBound(ColCrit)
For j = 4 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
For x = 0 To .ListCount - 1
For y = 0 To .ListCount - 1
If .List(x) < .List(y) Then
strTemp = .List(x)
.List(x) = .List(y)
.List(y) = strTemp
End If
Next y
Next x
End With
End Sub |
Partager