Macro to create pivotchart problems

S

seed

Put together a quick macro to assemble a pivotchart, nothing fancy just ran
through it recording and tried to run it on the same data afterwards, and
have come upon this error:

Run-time error '1004':
Unable to get the PivotFields property of the pivottable class

When I go to debug, the error is occurring at the asterisked line:

Cells.Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'Check results'!C1:C5").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
Charts.Add
ActiveChart.Location Where:=xlLocationAsNewSheet
* With ActiveChart.PivotLayout.PivotTable.PivotFields("TEST_LOCATION")
.Orientation = xlPageField
.Position = 1
End With

Is there a workaround? Something I've missed?

Thanks,

Ryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top