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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh pivot tables

Status
Not open for further replies.

GLENEE

Programmer
Feb 9, 2005
64
0
0
GB
I want the pivot tables in an Excel 97 spreadsheet to refresh automatically when a user makes a change. The code used on save(from a recorded macro) is :

[Worksheets("Sheet1").select
Worksheets("Sheet1").PivotTables(1).PivotTable "", xlDataAndLabel
Application.CommandBars("PivotTable").Visible = True
Worksheets("Sheet1").PivotTables(1).RefreshTable
Application.CommandBars("PivotTable").Visible = False]

I get runtime error 1004 "RefreshTable method of PivotTable class failed"
The refresh works fine when run as a macro.
Thanks


 
Use the worksheet_CHANGE event


code would be similar to

for each pt in thisworkbook.pivottables
pt.refreshtable
next

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top