Pivot Table Macro

Microsoft Office 2007 professional (aca...
June 16, 2010 at 03:45:50
Specs: Excel 2007

I'm facing the below case wit pivot table and i don't know why

I'm using the below code for inserting pivot table in a workbook sheet
Now i'm trying to use it in another workbook with the same structure and sheet names but it fails and gives me

Run Error '5' :
Invalid procedure or argument

i even i changed table name to PivotTable2 it still make the error

ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"table1", Version:=xlPivotTableVersion10).CreatePivotTable TableDestination _
:="Design Summary!R1C1", TableName:="PivotTable1", DefaultVersion:= _

Can any one help with this?

See More: Pivot Table Macro

Report •

June 16, 2010 at 08:51:16

Are you sure this line actually works in the original workbook.

The function to create a new pivot table is 'Add', not 'Create'
Also Version for a pivot table is read only, so you cannot set it, which is what this appears to do.

In addition, I see that the code refers to "table1". I am guessing that this is a named range, so there will have to be a range named "table1" in the new workbook.

I do not have Excel 2007 on this PC, so I can't test if the Visual Basic code model for Pivot tables has been changed from Excel 2003. If it hasn't then it seems that this line of code will not work as originally written.


Report •
Related Solutions

Ask Question