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?
 

Forum statistics

Threads
1,081,690
Messages
5,360,614
Members
400,592
Latest member
badgergurl

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top