Runtime Error Message - Pivot Refresh Macro

jkchild

Board Regular
Joined
May 24, 2006
Messages
167
Hi

I've created a Command Button from the Control Toolbox menu and added the following code using the view code option.

When I click the button I receive the following message:
"Run time error 1004 application defined or object defined error"
When I click debug the 2nd line of code is highlighted yellow.

Is there something wrong with the piece of code??
Thanks
J

Private Sub CommandButton1_Click()
Sheets("Summary").Range("A6").QueryTable.Refresh BackgroundQuery:=True
End Sub

The pivot table is on sheet Summary and the pivot starts from cell A4
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
No it's not a query table......It's a pivot table.

Do I just need to update Query Table with Pivot table in the formula? Or can you advise what I do need to do

Thanks
J
 
Upvote 0
I would advise you to record a macro while refreshing the pivot table manually. That will give you some code.
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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