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
| Private Sub UserForm_Initialize()
Dim i, a, b As Integer
Dim cel As Range
Dim strTemp As String
ComboBox33.Value = ""
ComboBox66.Value = ""
dernLigne = Sheets("ITEM").Range("E" & Rows.Count).End(xlUp).Row
'ça marche pour la première liste
For i = 2 To dernLigne
ComboBox33 = Sheets("ITEM").Range("E" & i)
If ComboBox33.ListIndex = -1 Then ComboBox33.AddItem Sheets("ITEM").Range("E" & i)
Next i
'ça ne marche pas pour la seconde
With Sheets("AFFECTATION")
For Each cel In Range("N3:N300")
If cel.Value <> 0 Then Me.ComboBox66.AddItem cel.Value
Next cel
With Me.ComboBox66
For a = 0 To .ListCount - 1
For b = 0 To .ListCount - 1
If .List(a) < .List(b) Then
strTemp = .List(a)
.List(a) = .List(b)
.List(b) = strTemp
End If
Next b
Next a
End With
End With
ComboBox33.Value = ""
ComboBox66.Value = ""
ComboBox33.SetFocus
End Sub |
Partager