Dim Plage As Range
With Worksheets("data")
Set Plage = .Range("A1:J" & .Range("A" & .Rows.Count).End(xlUp).Row)
End With
Dim wshTCD As Worksheet
Dim pvtTCD As PivotTable
'----------------------------------------- dô_Ôb -----------------------------------------
' 2.c) Création TCD
Set wshTCD = Worksheets("Synthèse")
For Each pvtTCD In wshTCD.PivotTables
pvtTCD.TableRange2.Clear
Next pvtTCD
Set pvtTCD = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=Plage) _
.CreatePivotTable(TableDestination:=wshTCD.Range("A1"), TableName:="TCD")
With pvtTCD
' * Filtre
With .PivotFields("État")
.Orientation = xlPageField
.Position = 1
End With
' * Lignes
With Sheets("synthèse").PivotTables("TCD").PivotFields("Gestionnaire")
.Orientation = xlRowField
.Position = 1
End With
' * Colonnes
Sheets("synthèse").PivotTables("TCD").AddDataField ActiveSheet.PivotTables("TCD"). _
PivotFields("Situation"), "Nombre de Situation", xlCount
End With
End With