Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Macro To Update Pivot Tables on Several Worksheets

I have less than a little knowledge of Macros and VBA.
I know how to create a Macro that follows my Mouse clicks etc.......
Can someone show me a Macro to update several Pivot Tables on several
Worksheets in the same work book. The tables all use the same data. I'm using
Excel 2003 SP3
Thank, You too much
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Macro To Update Pivot Tables on Several Worksheets

On Aug 18, 1:41*pm, Gringarlow
wrote:
I have less than a little knowledge of Macros and VBA.
I know how to create a Macro that follows my Mouse clicks etc.......
Can someone show me a Macro to update several Pivot Tables on several
Worksheets in the same work book. The tables all use the same data. I'm using
Excel 2003 SP3
Thank, You too much


Gringarlow,

There is some sample code below for updating pivot tables through the
worksheets within the active workbook.

Best,

Matthew Herbert

Sub PivotTableRefresh()
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."

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Macro To Update Pivot Tables on Several Worksheets

Matthew,

I added a "ActiveWorkbook.RefreshAll" to the front of your code & in only
refreshes the data sheet, leaving the pivot tables untouched (see below).
I'm trying 1st refresh the data sheets connected to an outside database.
Then refresh all of the end user's custom pivot tables. I'd also like to add
a refresh date to all the sheets in the workbook in (Z1).

Private Sub CmdRefreshAll_Click()
'Refresh data sheets for outside data sources
ActiveWorkbook.RefreshAll
MsgBox "All Data Sheets are updated, click ok to update Pivot tables"

'Refresh Pivot tables
Dim Wks As Worksheet
Dim pvtTable As PivotTable

Application.ScreenUpdating = False

For Each Wks In ActiveWorkbook.Worksheets

For Each pvtTable In Wks.PivotTables

pvtTable.PivotCache.Refresh

Next pvtTable

Next Wks

MsgBox "All Data Sheets & Pivot Tables are updated"

End Sub

--
Thanks, Kevin


"Matthew Herbert" wrote:

On Aug 18, 1:41 pm, Gringarlow
wrote:
I have less than a little knowledge of Macros and VBA.
I know how to create a Macro that follows my Mouse clicks etc.......
Can someone show me a Macro to update several Pivot Tables on several
Worksheets in the same work book. The tables all use the same data. I'm using
Excel 2003 SP3
Thank, You too much


Gringarlow,

There is some sample code below for updating pivot tables through the
worksheets within the active workbook.

Best,

Matthew Herbert

Sub PivotTableRefresh()
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."

End Sub

Reply
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
Update linked pivot tables when page changes in main pivot Needing Help Excel Discussion (Misc queries) 0 May 9th 09 11:11 PM
Update multiple pivot tables Svilen Pachedzhiev Excel Programming 4 July 10th 08 01:42 PM
Pivot Tables will not update Jonesy Excel Discussion (Misc queries) 0 July 26th 07 10:02 AM
I can not update my pivot charts and tables. Pivot Tables 101 Excel Discussion (Misc queries) 4 December 19th 06 09:10 PM
Update pivot tables automatically minrufeng[_8_] Excel Programming 0 August 24th 05 02:41 AM


All times are GMT +1. The time now is 07:22 PM.

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"