Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim p As PivotItem, s As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
s = .Calculation
.Calculation = xlCalculationManual
End With
If Not Intersect(Target, Range("G1")) Is Nothing Then
With Me.PivotTables(1).PivotFields("NumCpt")
If Target.Value = "Tous" Then
.CurrentPage = "(Tous)"
Else
For Each p In .PivotItems
If p.Value = Target.Value Then .CurrentPage = Target.Value
Next p
End If
End With
End If
If Not Intersect(Target, Range("G3")) Is Nothing Then
With Me.PivotTables(1).PivotFields("NumTier")
If IsEmpty(Target.Value) Then
.CurrentPage = "(Vide)"
ElseIf Target.Value = "Tous" Then .CurrentPage = "(Tous)"
Else
For Each p In .PivotItems
If p.Value = Target.Value Then .CurrentPage = Target.Value
Next p
End If
End With
End If
If Not Intersect(Target, Range("G5,I5")) Is Nothing Then
For Each p In Me.PivotTables(1).PivotFields("Periode").PivotItems
p.Visible = True
Next p
If Target.Address = "$G$5" Then
For Each p In Me.PivotTables(1).PivotFields("Periode").PivotItems
If CDbl(p.Value) < Target Then p.Visible = False
Next p
Else
For Each p In Me.PivotTables(1).PivotFields("Periode").PivotItems
If p.Value > Target Then p.Visible = False
Next p
End If
End If
With Application
.Calculation = s
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub