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
| Private Sub UserForm_Initialize()
Dim Li&, LiDonnees&, ColDonnees&, i& 'long
Dim ValeurCherchee$ ' string
Dim Doublon As Boolean
Li = 0: LiDonnees = 4: ColDonnees = 1
ComboBox1.Clear
Do Until Cells(LiDonnees, ColDonnees).Value = Empty
'Tester doublon
Doublon = False
ValeurCherchee = Cells(LiDonnees, ColDonnees).Value
For i = 0 To ComboBox1.ListCount - 1
If ComboBox1.List(i, 0) = ValeurCherchee Then
ComboBox1.List(i, 1) = Cells(LiDonnees, ColDonnees + 4).Value
Doublon = True
Exit For
End If
Next
If Not Doublon Then
ComboBox1.AddItem Cells(LiDonnees, ColDonnees).Value
ComboBox1.List(ComboBox1.ListCount - 1, 1) = Cells(LiDonnees, ColDonnees + 4).Value
End If
LiDonnees = LiDonnees + 1
Loop
TextBox1.Value = ""
TextBox2.Value = ""
'ComboBox1.Clear
ComboBox2.Clear
With ComboBox2
For i = 1 To 12
.AddItem i
Next
End With
End Sub |
Partager