Sub CREATIONTCD()
Dim ws As Worksheet, pc As PivotCache, Tcd As PivotTable
Set ws = Sheets("TCD")
With ws
If .PivotTables.Count > 0 Then
.PivotTables(1).TableRange2.Delete
End If
Set pc = ThisWorkbook.PivotCaches.Add(xlDatabase, Sheets("basededonnees").Range("PLAGE"))
Set Tcd = pc.CreatePivotTable(.Range("A1"))
End With
With Tcd
.PivotFields("xxx").Orientation = xlRowField
.PivotFields("yy").Orientation = xlRowField
.PivotFields("ooo").Orientation = xlRowField
With .PivotFields("yy")
.Orientation = xlDataField
.Function = xlSum
End With
End With
End Sub