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
|
Dim F As Worksheet, dm As Object, dy As Object, dl As Long, Tb, i As Long, dmBis As Object
Private Sub Worksheet_Activate()
Set dy = CreateObject("Scripting.Dictionary")
Set F = Worksheets("BD")
dl = F.Range("A" & Rows.Count).End(xlUp).Row
Tb = F.Range("A2:A" & dl).Value2
dy("Tout") = ""
For i = LBound(Tb) To UBound(Tb)
If Not dy.exists(Year(Tb(i, 1))) Then dy(Year(Tb(i, 1))) = ""
Next i
Me.ComboBox1.List = dy.keys
End Sub
Private Sub ComboBox1_Change()
Call CodeMois
Set dm = CreateObject("Scripting.Dictionary")
Set dmBis = CreateObject("Scripting.Dictionary")
With Worksheets("BD")
Tb = .Range("A2:A" & .Cells(.Rows.Count, 1).End(xlUp).Row).Value2
End With
With Me
.ComboBox2.Clear
If .ComboBox1 = "Tout" Then
.ComboBox2.List = sMois
Else
For i = LBound(Tb, 1) To UBound(Tb, 1)
If Year(Tb(i, 1)) = CLng(.ComboBox1.Value) Then dm(Month(Tb(i, 1))) = ""
Next i
For i = 1 To 12
If dm.exists(i) Then dmBis(i) = sMois(i)
Next i
.ComboBox2.List = dmBis.items
End If
End With
End Sub |
Partager