greg0ire
XLDnaute Nouveau
Bonjour à tous! J'essaie d'utiliser la puissance des pivots tables dans un projet mais on dirait que c'est trop puissant pour moi en fait... Etant donne ce code :
J'aimerais savoir pourquoi j'ai une erreur 1004 : "Unable to get the PivotItems property of the PivotFields Class" a l'execution de la derniere ligne de code alors que l'avant dernière fonctionne parfaitement...
J'obtiens pourtant bien une pivotTable comme je la desire mais la recuperation des donnees echoue...pourquoi? Dans la doc on ne voit pas de PivotItems property, mais une method PivotItems oui. Qu'est-ce qui fait que pivotitems est interpretée comme propriete?
Code:
.Cells(1, 1).Select
Range(Selection, Selection.Offset(0, 1)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
Selection).CreatePivotTable TableDestination:="", _
TableName:="MaxMinAvgPivotTable", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("MaxMinAvgPivotTable").AddDataField ActiveSheet. _
PivotTables("MaxMinAvgPivotTable").PivotFields("Elapsed time"), _
"Sum of Elapsed time", xlSum
With ActiveSheet.PivotTables("MaxMinAvgPivotTable").PivotFields(xcol)
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("MaxMinAvgPivotTable").PivotSelect "", xlDataAndLabel, True
ActiveSheet.PivotTables("MaxMinAvgPivotTable").PivotFields("Sum of Elapsed time"). _
Function = xlMax
For Each featureValue In difStrCol(col, refCell)
'MIN
ActiveSheet.PivotTables("MaxMinAvgPivotTable").PivotFields("Max of Elapsed time"). _
Function = xlMin
Debug.Print ActiveSheet.PivotTables("MaxMinAvgPivotTable").PivotFields(xcol).PivotItems(1).SourceNameStandard
refCell.Offset(0, 1).Value = ActiveSheet.PivotTables("MaxMinAvgPivotTable"). _
PivotFields(xcol).PivotItems(featureValue).DataRange().Value
J'obtiens pourtant bien une pivotTable comme je la desire mais la recuperation des donnees echoue...pourquoi? Dans la doc on ne voit pas de PivotItems property, mais une method PivotItems oui. Qu'est-ce qui fait que pivotitems est interpretée comme propriete?
Dernière édition: