![]() |
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 |
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 |
All times are GMT +1. The time now is 09:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com