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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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,605
Messages
6,120,476
Members
448,967
Latest member
visheshkotha

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