Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PivotTable RefreshTable 2

Status
Not open for further replies.

Stretchwickster

Programmer
Joined
Apr 30, 2001
Messages
1,746
Location
GB
I've added a command button directly to my excel sheet. Then I recorded what happens when I refresh my table and it generated the following VBA code:
Code:
ActiveSheet.PivotTables("PivotTable3").PivotSelect "'4'", xlDataAndLabel
  ActiveSheet.PivotTables("PivotTable3").RefreshTable
  ActiveSheet.PivotTables("PivotTable4").PivotSelect "'5'", xlDataAndLabel
  ActiveSheet.PivotTables("PivotTable4").RefreshTable

I pasted this code into my command button click event but when I click it at run-time, it gives the following error: "RefreshTable method of PivotTable class failed". Anyone know what the problem is or how to get it to work properly.

Any help would be much appreciated!

Clive [infinity]
 
If the button is a "Controls Toolar" button, you will need to set the "Take Focus On Click" property to false otherwise there is no "Activesheet" as the button has the focus

Plus, I would use
For each pt in activesheet.pivottables
pt.refresh
next

HTH Rgds
Geoff

Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur
 
Thanks Geoff! Once again you solve my problem in record time!! Clive [infinity]
 
That's twice today yu've helped me out Geoff...

I'm just going to have to do a search on you and read all your posts so I won't have to beat my head against the wall anymore. :-)

Onwards,

Q-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top