et si tu essayes de lancer la macro 2 fois à la suite cela fonctionne t'il ?
Merci
J'ai utilisé le code suivant mais il me marque erreur de compatibilité
Public Sub creer_TCD() 'Macro qui sert à créer automatiquement un TCD
Dim rng As Range
Dim ptCache As PivotCache ' Dim --> création de variables
Dim pt As PivotTable
Application.ScreenUpdating = False
Set rng = Range("C:C,D:D") 'Sélection cellules concernées
Set ptCache = ActiveWorkbook.PivotCaches.Create _
(SourceType:=xlDatabase, _
SourceData:=rng, _
Version:=xlPivotTableVersion12)
Worksheets.Add
Set pt = ptCache.CreatePivotTable _
(TableDestination:=[C3], _
TableName:="TCD_1", _
DefaultVersion:=xlPivotTableVersion12) 'Nom et destination du TCD (ici le TCD s'appelle TCD_1 et on le place en C3
pt.ManualUpdate = True
pt.AddFields RowFields:="nom client", PageFields:="N*dossier" 'Paramètre TCD :filtre du rapport et étiquette de ligne
pt.ManualUpdate = False
Set pt = Nothing
Set ptCache = Nothing
Set rng = Nothing
End Sub