Run-time error '1004': Unable to get the PivotTables property of the Worksheet class

ratedr95

New Member
Joined
Oct 5, 2016
Messages
7
Hi,

I am trying to get a macro to run to automatically change the filters in a Pivot table linked to a Cube.

I recorded the macro to begin with but I always get the error listed in the title of this thread.

My code is:

Code:
Sub CubeReconcile()
    
    Application.ScreenUpdating = False
    Workbooks.Open ("P:\Desktop\Cube v1.xlsm")
    ThisWorkbook.Activate
    Application.ScreenUpdating = True
    
    ActiveSheet.PivotTables("ECBv1.0").PivotFields( _
        "[Business_Unit].[Business Unit Hierarchy].[Business_Unit]"). _
        ClearAllFilters

    ActiveSheet.PivotTables("Cubev1.0").PivotFields( _
        "[Business_Unit].[Business Unit Hierarchy].[Business_Unit]"). _
        CurrentPageName = _
        "[Business_Unit].[Business Unit Hierarchy].[Business_Unit].&[European]"
    
End Sub

The line it is pointing to is the final line in the code beginning with "[Business_Unit]..

Any ideas that could be the reason for the error?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
That error indicates that either the pivot table name is wrong, or you have the wrong sheet active.
 
Upvote 0
I removed all sheets from the file (Aside the one with the table on), re-recorded the Macro and then tried to run the Macro again and it is still giving the same error highlighting the same line of code.

Any other suggestions?
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,824
Members
449,050
Latest member
Bradel

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