Run Time Error 1004 Pivot Table Name is not Valid

Captain Smith

Active Member
Joined
Feb 28, 2003
Messages
324
I get this error when trying to refresh the Pivot table using either manual refresh or the code below? What the heck is causing this and how do I fix the Pivot table? Thanks.

Sub PivotStatus()
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Are you certain that the pivot table is named exactly as the code says it is? Right click on the pivot table, left click on Table Options and verify the the name is PivotTable3.

Otherwise, you did not say what kind of error you are getting so post back and specify the error number and message for a more relevant suggestion.
 
Upvote 0
There should be no logical reason for that. Usually 1004 refers to a protected sheet. In your case it's an invalid name.

I know you are sure, but try this anyway.

Select a cell in your pivot table.

Press Alt+F11 and then Ctrl+G and there in the Immediate Window type in or paste in
? activecell.PivotCell.Parent.name
and press the Enter key.

Now carefully copy that name from the Immediate Window and paste it into your macro and try the macro again.
 
Upvote 0
Never mind, i found my problem. Another piece of my code changed the header to a different name, causing the pivot not to work. Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,214,807
Messages
6,121,679
Members
449,047
Latest member
notmrdurden

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