runtime error 5 with recorded macro

hwkeyser

Board Regular
Joined
Jun 7, 2011
Messages
116
Hi everyone,

i read a half dozen threads now trying to figure out why my simple, "delete old pivot table then add new pivot table" macro is returning runtime error 5.

This seems to be one of the recognized issues with XL'07, but i thought i'd put mine out there for assistance and guidance.

Code:
    Columns("A:A").Select
    Selection.Delete Shift:=xlToLeft
    Selection.Insert Shift:=xlToRight
    Range("A1").Select
[COLOR="Red"]        ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "Compiled List!R1C1:R5985C7", Version:=xlPivotTableVersion12). _
        CreatePivotTable TableDestination:="'Upcoming and Current List'!R1C1", _
        TableName:="PivotTable3", DefaultVersion:=xlPivotTableVersion12[/COLOR]

The error stems from this point right here.

the error reads: invalid procedure call or argument.

Any help would be greatly appreciated,

Thanks,

HK
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Do the sheets "Compiled List" and "Upcoming and Current List" exist in the workbook?
 
Upvote 0
yes. They are neither new nor modified in title.

Also, i've tried the names of both sheets with the single quotations encompassing (the above example only shows it around the destination).. the error occurs even when both are encompassed.
 
Upvote 0
I tried your code to create the pivot with different sheet names and smaller data and it worked fine. The three lines above it do give me an error (1004) when I try to delete the same pivot.
 
Upvote 0
I changed "Upcoming and Current Lists" to "Upcoming_and_Current_Lists" and now the thing works perfectly. I hate when its those sorts of things which stall up the application.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,588
Members
449,089
Latest member
Motoracer88

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