Je cherche à faire un tableau croisé dynamique à l'aide d'une macro.
Mais un message d'erreur s'affiche lorsque j'exécute le code fourni par l'enregistreur de macros (je sais que c'est mal).
Ci-joint le fichier (simple) qui pose problème :
http://www.cijoint.fr/cjlink.php?file=cj200908/cijITG1Saz.xls
et voici le code fourni par l'enregistreur (il est aussi dans le fichier) :
Sub TestTCD()
'
' TestTCD Macro
' Macro enregistrée le 19/08/2009 par LIBGR15
'
'
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Feuil1!C1:C7").CreatePivotTable TableDestination:="", TableName:= _
"Tableau croisé dynamique1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables("Tableau croisé dynamique1")
.ColumnGrand = False
.RowGrand = False
End With
ActiveSheet.PivotTables("Tableau croisé dynamique1").AddFields RowFields:= _
Array("TITRE", "Données")
With ActiveSheet.PivotTables("Tableau croisé dynamique1").PivotFields("SALAIRE" _
)
.Orientation = xlDataField
.Position = 1
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique1").PivotFields("SALAIRE" _
)
.Orientation = xlDataField
.Caption = "Somme de SALAIRE2"
.Function = xlSum
End With
Range("B3").Select
With ActiveSheet.PivotTables("Tableau croisé dynamique1").DataPivotField
.Orientation = xlColumnField
.Position = 1
End With
End Sub
Merci d'avance pour vos réponses, et bon courage.
