Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dkso
 
Posts: n/a
Default Excel Pivot tables refresh

I have a few database queries in a spreadsheet, each query is then
referenced by it's own pivot table. I then have a VBA button on the main
"Report" page that when pressed refreshes all "ThisworkBook.RefreshAll".
Problem is that I have to press is more than once. I'm guessing it has
something to do with the order in which I added the queries and pivot
tables, but is there a way to have the VBA code refresh all correctly.
I have tried putting the code in twice but it runs the second line before
the first one has completed all the queries/tables.

Dean

--

http://www.dkso.co.uk/
http://homepage.ntlworld.com/dkso


  #2   Report Post  
Anne Troy
 
Posts: n/a
Default

Hi, Dkso. Why don't you try something like this, which refreshes when the
sheet is activated.
http://www.vbaexpress.com/kb/getarticle.php?kb_id=80
*******************
~Anne Troy

www.OfficeArticles.com
www.MyExpertsOnline.com


"Dkso" wrote in message
...
I have a few database queries in a spreadsheet, each query is then
referenced by it's own pivot table. I then have a VBA button on the main
"Report" page that when pressed refreshes all "ThisworkBook.RefreshAll".
Problem is that I have to press is more than once. I'm guessing it has
something to do with the order in which I added the queries and pivot
tables, but is there a way to have the VBA code refresh all correctly.
I have tried putting the code in twice but it runs the second line before
the first one has completed all the queries/tables.

Dean

--

http://www.dkso.co.uk/
http://homepage.ntlworld.com/dkso




  #3   Report Post  
Debra Dalgleish
 
Posts: n/a
Default

You could refresh the queries, then refresh the pivot caches, e.g.:

'===============================
Sub MyRefreshAll()

Dim ws As Worksheet
Dim qry As QueryTable
Dim pc As PivotCache

For Each ws In ActiveWorkbook.Worksheets
For Each qry In ws.QueryTables
qry.BackgroundQuery = False
qry.Refresh
Next qry
Next ws

For Each pc In ActiveWorkbook.PivotCaches
pc.Refresh
Next pc

MsgBox "Queries and Pivot caches have been refreshed"

End Sub
'===============================

Dkso wrote:
I have a few database queries in a spreadsheet, each query is then
referenced by it's own pivot table. I then have a VBA button on the main
"Report" page that when pressed refreshes all "ThisworkBook.RefreshAll".
Problem is that I have to press is more than once. I'm guessing it has
something to do with the order in which I added the queries and pivot
tables, but is there a way to have the VBA code refresh all correctly.
I have tried putting the code in twice but it runs the second line before
the first one has completed all the queries/tables.

Dean



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #4   Report Post  
Dkso
 
Posts: n/a
Default

I knew someone out there would have a good suggestion.

Thanks, I'll give them a go.

Dean
"Dkso" wrote in message
...
I have a few database queries in a spreadsheet, each query is then
referenced by it's own pivot table. I then have a VBA button on the main
"Report" page that when pressed refreshes all "ThisworkBook.RefreshAll".
Problem is that I have to press is more than once. I'm guessing it has
something to do with the order in which I added the queries and pivot
tables, but is there a way to have the VBA code refresh all correctly.
I have tried putting the code in twice but it runs the second line before
the first one has completed all the queries/tables.

Dean

--

http://www.dkso.co.uk/
http://homepage.ntlworld.com/dkso



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
Blank Cells in Pivot Tables Greg Excel Discussion (Misc queries) 1 March 16th 05 09:23 PM
Pivot Tables Barb R. Excel Discussion (Misc queries) 0 March 9th 05 02:35 PM
How can deleted data reappear in a refreshed pivot table in Excel excel_user123456 Excel Discussion (Misc queries) 3 February 23rd 05 08:34 PM
Product Function in Pivot Tables from Multiple Consolidation Range bbishop222 Excel Worksheet Functions 0 February 22nd 05 04:55 PM
convert excel list to pivot table GI Excel Discussion (Misc queries) 0 December 6th 04 06:45 PM


All times are GMT +1. The time now is 07:10 AM.

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"