LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default refresh multiple pivot tables in workbook

Hi all. I have been trying to use this code I found from another answered
question from Matthew Herbert relating to refreshing pivot tables within a
workbook:

Dim Wks As Worksheet
Dim pvtTable As PivotTable

'don't allow screen updating because it takes time
Application.ScreenUpdating = False

'loop through each worksheet
For Each Wks In ActiveWorkbook.Worksheets

'loop through each pivot table in the worksheet
For Each pvtTable In Wks.PivotTables

'refresh the pivot table
pvtTable.PivotCache.Refresh

Next pvtTable

Next Wks

'tell the user you are done with the refresh
MsgBox "The pivot tables have been updated."


I have a large workbook and some sheets contain pivot tables and some don't
and they are from a variety of datasets- all within the workbook. I have
tried a number of different programatic solutions but they don't seem to hit
the mark. This one appears to be doing something but then I come up with an
error on "pvtTable.PivotCache.Refresh". I suspect that it might hit a
worksheet that doesn't have a pivot table. Can anyone tell me how to modify
this code to skip any sheet that doesn't have a pivot table, or can you tell
me if this code would cope with sheets without pivot tables??

Thanks for your help.
Gai
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to Refresh inbound data sheets, then Refresh Pivot Tables AFSSkier Excel Programming 3 September 4th 09 07:59 PM
Refresh Pivot Tables VJ Excel Programming 5 September 20th 06 09:44 AM
Refresh multiple pivot tables Latasha at PBG Excel Discussion (Misc queries) 0 May 2nd 06 04:04 PM
Refresh all pivot tables in a workbook nc Excel Discussion (Misc queries) 3 June 22nd 05 06:37 PM
Refresh Multiple Pivot Tables Paul Excel Programming 1 August 18th 04 12:47 PM


All times are GMT +1. The time now is 08:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"