Option Explicit
Sub TCD()
Dim ShtSrc As Worksheet, ShtDst As Worksheet
Application.ScreenUpdating = False
Set ShtSrc = ActiveSheet
If ShtSrc.Range("A65536").End(xlUp).Row > 1 Then
Set ShtDst = Sheets.Add
On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets("TCD " & ShtSrc.Name).Delete
Application.DisplayAlerts = True
On Error GoTo 0
ShtDst.Name = "TCD " & ShtSrc.Name
ThisWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'" & ShtSrc.Name & "'!" & ShtSrc.UsedRange.Address).CreatePivotTable TableDestination:="'" & ShtDst.Name & "'!R1C1", TableName:="TCD " & ShtSrc.Name, DefaultVersion:=xlPivotTableVersion10
With ShtDst.PivotTables(ShtDst.Name)
With .PivotFields("Stat ")
.Orientation = xlRowField
.Position = 1
End With
.AddDataField .PivotFields("Ventes "), "Somme de Ventes", xlSum
.AddDataField .PivotFields("LivrÚe "), "Somme de Livrée", xlSum
End With
ThisWorkbook.ShowPivotTableFieldList = False
Set ShtDst = Nothing
End If
Set ShtSrc = Nothing
Application.ScreenUpdating = True
End Sub