Bonjour
@Dranreb,
Merci,
ça fonctionne ainsi :
-------------------
Sub test()
Dim monPivIt As Object, Mavariable
Mavariable1 = ThisWorkbook.Sheets("p11").Range("c4").Value
Mavariable2 = ThisWorkbook.Sheets("p11").Range("c5").Value
Mavariable3 = ThisWorkbook.Sheets("p11").Range("c6").Value
Mavariable4 = ThisWorkbook.Sheets("p11").Range("c7").Value
Mavariable5 = ThisWorkbook.Sheets("p11").Range("c8").Value
'Application.ScreenUpdating = False
With ActiveSheet.PivotTables("Tableau croisé dynamique2").PivotFields("magasin")
For Each monPivIt In .PivotItems
monPivIt.Visible = True
Next
On Error Resume Next
For Each monPivIt In .PivotItems
If (monPivIt.Name <> Mavariable1) And (monPivIt.Name <> Mavariable2) And (monPivIt.Name <> Mavariable3) And (monPivIt.Name <> Mavariable4) And (monPivIt.Name <> Mavariable5) Then monPivIt.Visible = False
Next
End With
'Application.ScreenUpdating = True
End Sub
-------------------
Merci pour la proposition d'un seule boucle : ça fonctionne
🙂