Macro to make pivot tables works in 2003 but not 2007

Fool_Working

New Member
Joined
Mar 23, 2006
Messages
31
Hi, I have a macro that makes pivot tables based on changing data. I wrote it in Excel 2003, and it works fine still in 2003.

However, my computer was recently upgraded to Excel 2007. The code errors out whenever it hits the pivot table macro now. I tried re-recording the pivot table build in 2007 and replacing my old code, but it still errors out. Help?

Here is my original pivot table code at the section where the error happens:

Code:
    ActiveSheet.Name = "Detail"
    ActiveCell.SpecialCells(xlLastCell).Select
  
    PivotReference = "'Detail'!R1C1:" & ActiveCell.Address
'Create Pivot Table of Total Costs $
        ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
        PivotReference).CreatePivotTable TableDestination:= _
        "'Pivot Summary'!R13C1", _
        TableName:="PivotTable2", DefaultVersion:=xlPivotTableVersion10

Here is my 2007 code, that is still getting the same error:
Code:
  ActiveSheet.Name = "Detail"
    ActiveCell.SpecialCells(xlLastCell).Select
  
    PivotReference = "'Detail'!R1C1:" & ActiveCell.Address
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        PivotReference, Version:=xlPivotTableVersion12). _
        CreatePivotTable TableDestination:="Pivot Summary!R4C4", TableName:="PivotTable1" _
        , DefaultVersion:=xlPivotTableVersion12

There is additional code afterward to set up the rows, columns, values, etc... but it doesn't even get to that point, so I didn't include that code.
Any suggestions?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top