Sub Ventiler()
Chemin = "T:\TEMP\"
Application.ScreenUpdating = False
ActiveSheet.PivotTables("Tableau croisé dynamique48").ShowPages PageField:="agent"
For Each Ws In ThisWorkbook.Worksheets
If Ws.Name <> "base" And Ws.Name <> "Feuil2" Then
Ws.Move
Set WK2 = ActiveWorkbook
Set WS2 = ActiveSheet
With WS2.PivotTables(1)
WS2.Range(Mid(WS2.PivotTables(1).DataBodyRange.Address, InStrRev(WS2.PivotTables(1).DataBodyRange.Address, ":") + 1, 8)).ShowDetail = True
.ChangePivotCache ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:="Tableau1")
End With
WK2.SaveAs Filename:=Chemin & WS2.Name & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
WK2.Close
End If
Next Ws
End Sub