Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default data refresh all worksheets in a workbook using vba

I have set up a Database query and query will get data to populate all
worksheets in a workbook. At the moment I have to go to each worksheet and
press refresh data button to update. Is there a VBA code whereby I could
refresh all worksheets in the workbook.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default data refresh all worksheets in a workbook using vba

Sub RefreshQrys()
For Each wSht In ThisWorkbook.Worksheets
For Each qt In wSht.QueryTables
qt.Refresh
Next
For Each pt In wSht.PivotTables
pt.RefreshTable
Next
Next
End Sub


Works best if none of the queries have the "BackgroundQuery" property set to
true as it ensures that they are refreshed 1 at a time

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"Sarah W" <Sarah wrote in message
...
I have set up a Database query and query will get data to populate all
worksheets in a workbook. At the moment I have to go to each worksheet and
press refresh data button to update. Is there a VBA code whereby I could
refresh all worksheets in the workbook.

Thanks



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
Refresh pivot table in workbook A when changing a cell in workbook gildengorin Excel Worksheet Functions 2 March 17th 09 04:59 PM
REFRESH DATA in all Worksheets upon open of workbook sfleck Excel Discussion (Misc queries) 0 October 19th 07 12:08 AM
Create refresh button in worksheet to refresh Pivot Table Data Ron Excel Worksheet Functions 1 October 13th 07 01:20 AM
XL 2007: Pivot Refresh slow when data resides in another workbook funnybroad Excel Discussion (Misc queries) 1 May 31st 07 07:31 AM
Pivot Table REFRESH Flaw -- Saves Old Data in Selection Area AFTER REFRESH Ken Roberts Excel Programming 3 September 11th 03 06:02 AM


All times are GMT +1. The time now is 12:14 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"