Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default macro refinement

I use the following macro in several spreadsheets, to automate the
spreadsheet and make it easier for end users. It loops through and updates
all data tables, then loops through and updates all the pivots tables.

The problem is, one file that I use this on, has seven different pivot
tables, that are all linked together. When I created the 2nd through seventh
pivot table, I told the pivot table wizard that the data source was the 1st
pivot table.

As you know, when they are linked in this way, you only have to refresh one
of the pivot tables, and they all refresh. With this macro though, it
refreshes the first one, which refreshes all of them, then goes to the second
pivot and refreshes all seven again, and so on, and so on.

Is there any way for the macro to only refresh the original, and not refresh
all the ones that are linked to it? As it is now, it takes longer than I
would like for the macro to finish.

Sub Auto_Open()
'
' Auto_Open Macro
'

Dim ws As Worksheet
Dim qt As QueryTable
Dim pt As PivotTable

For Each ws In ThisWorkbook.Worksheets
For Each qt In ws.QueryTables
qt.Refresh False
Next qt
Next ws

For Each ws In ThisWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default macro refinement

Untested...

Thisworkbook.refreshall

Maybe it'll just do everything once????



Jonathan Cooper wrote:

I use the following macro in several spreadsheets, to automate the
spreadsheet and make it easier for end users. It loops through and updates
all data tables, then loops through and updates all the pivots tables.

The problem is, one file that I use this on, has seven different pivot
tables, that are all linked together. When I created the 2nd through seventh
pivot table, I told the pivot table wizard that the data source was the 1st
pivot table.

As you know, when they are linked in this way, you only have to refresh one
of the pivot tables, and they all refresh. With this macro though, it
refreshes the first one, which refreshes all of them, then goes to the second
pivot and refreshes all seven again, and so on, and so on.

Is there any way for the macro to only refresh the original, and not refresh
all the ones that are linked to it? As it is now, it takes longer than I
would like for the macro to finish.

Sub Auto_Open()
'
' Auto_Open Macro
'

Dim ws As Worksheet
Dim qt As QueryTable
Dim pt As PivotTable

For Each ws In ThisWorkbook.Worksheets
For Each qt In ws.QueryTables
qt.Refresh False
Next qt
Next ws

For Each ws In ThisWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default macro refinement

This seemed to updated the data table, but didn't touch the pivot tables.
Any other ideas?

"Dave Peterson" wrote:

Untested...

Thisworkbook.refreshall

Maybe it'll just do everything once????



Jonathan Cooper wrote:

I use the following macro in several spreadsheets, to automate the
spreadsheet and make it easier for end users. It loops through and updates
all data tables, then loops through and updates all the pivots tables.

The problem is, one file that I use this on, has seven different pivot
tables, that are all linked together. When I created the 2nd through seventh
pivot table, I told the pivot table wizard that the data source was the 1st
pivot table.

As you know, when they are linked in this way, you only have to refresh one
of the pivot tables, and they all refresh. With this macro though, it
refreshes the first one, which refreshes all of them, then goes to the second
pivot and refreshes all seven again, and so on, and so on.

Is there any way for the macro to only refresh the original, and not refresh
all the ones that are linked to it? As it is now, it takes longer than I
would like for the macro to finish.

Sub Auto_Open()
'
' Auto_Open Macro
'

Dim ws As Worksheet
Dim qt As QueryTable
Dim pt As PivotTable

For Each ws In ThisWorkbook.Worksheets
For Each qt In ws.QueryTables
qt.Refresh False
Next qt
Next ws

For Each ws In ThisWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws
End Sub


--

Dave Peterson

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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
League Ladder refinement of Sorting. Adeptus - ExcelForums.com Excel Programming 1 August 9th 05 08:59 AM
ROBBYN - RE -Code Refinement involving blank cell(s) COULD NOT POST FOLLOWUP ross Excel Programming 1 June 2nd 04 01:21 AM
Code Refinement involving blank cell(s) Robbyn Excel Programming 1 June 1st 04 01:16 AM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 08:56 PM.

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

About Us

"It's about Microsoft Excel"