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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
'pour les charger
Private Sub UserForm_Initialize()
Dim Dico As Object
Dim Plage As Range
Dim Cel As Range
'plage en colonne Q
With Worksheets("CG LOT1")
Set Plage = .Range(.Cells(2, 17), .Cells(.Rows.Count, 17).End(xlUp))
End With
'crée le dictionnaire
Set Dico = CreateObject("Scripting.Dictionary")
'parcour la plage et se sert du dico pour éliminer les doublons
'les dates dans les deux ListBox
For Each Cel In Plage
With Cel
If Dico.exists(.Value) = False Then
Dico.Add .Value, .Value
ListBox1.AddItem .Value
ListBox2.AddItem .Value
End If
End With
Next Cel
'tri les ListBox par ordre croissant
Tri ListBox1
Tri ListBox2
Set Dico = Nothing
End Sub
Sub Tri(Liste As MSForms.ListBox)
Dim Tempo
Dim I As Integer
Dim J As Integer
With Liste
For I = 0 To .ListCount - 1
For J = 0 To .ListCount - 1
'< croissant, > décroissant
If CDate(.List(I)) < CDate(.List(J)) Then
Tempo = .List(I)
.List(I) = .List(J)
.List(J) = Tempo
End If
Next J
Next I
End With
End Sub |
Partager