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
| Sub init_segments()
Application.ScreenUpdating = False
'Déclaration des variables
Dim Sli_C As SlicerCache: Dim Sli_Cs As SlicerCaches: Dim Sli As Slicer
Set Sli_Cs = ActiveSheet.Parent.SlicerCaches 'récupere tous les segments du classeur
If Sli_Cs Is Nothing Then Exit Sub 'si pas segment fin de la proc
'Boucle sur les segments de la feuille active pour les vider
For Each Sli_C In Sli_Cs
For Each Sli In Sli_C.Slicers
If Sli.Shape.Parent Is ActiveSheet Then
Sli_C.ClearManualFilter
Exit For
End If
Next Sli
Next Sli_C
'reinit d'un des segments
With ActiveWorkbook.SlicerCaches("Segment_Top_Maganer")
.SlicerItems("OUI").Selected = True
.SlicerItems("NON").Selected = False
End With
Application.ScreenUpdating = True
'Libération des variables
Set Sli_Cs = Nothing
Set Sli_C = Nothing
Set Sli = Nothing
End Sub |