Sub Filtrer()
Dim f As Worksheet
Dim Ctrl As Control
Dim LigneC As Integer
Dim PlageS As Range
Dim Col As String
' On Error GoTo fin
'Sélection
Application.ScreenUpdating = False
Set f = ActiveSheet
Col = Switch(f.Name = "Planning_général", "C", f.Name = "Planification du préventif", "H")
MsgBox Col ' pour test
With f
.Range("AA1:AA12").ClearContents
If .FilterMode Then .ShowAllData
For Each Ctrl In Me.Controls
If Ctrl.Object.Value = True Then
LigneC = Application.Max(2, .Range("AA23").End(xlUp).Row + 1)
MsgBox LigneC ' pour test
.Range("AA" & LigneC).Formula = "=MONTH(" & Col & "14)=" & Ctrl.Tag
End If
Next Ctrl
'Tri
Set PlageS = .Range("A13:M" & .Range("A" & Rows.Count).End(xlUp).Row)
PlageS.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
.Range("AA1:AA" & LigneC), Unique:=False
End With
End Sub