![]() |
Refreshing Query Tables
Suspect this is in a sheet module in which case, the unqualified references
will remain pointed at the sheet containing the module rather than the activesheet (which is your intent). The revision below should work if my assumption is correct. For Each ws In Worksheets ' ws.Activate For Each ws.query In QueryTables ws.query.Refresh BackgroundQuery:=False Next Next -- Regards, Tom Ogilvy "Simon Shaw" wrote in message ... I am trying to run a macro to refresh all query tables in my sheet. I am using the following code, but it does not seem to update the tables, but it doesn't error out either. any ideas? For Each ws In Worksheets ws.Activate For Each query In QueryTables query.Refresh BackgroundQuery:=False Next Next |
Refreshing Query Tables
"Tom Ogilvy" wrote in message ... Suspect this is in a sheet module in which case, the unqualified references will remain pointed at the sheet containing the module rather than the activesheet (which is your intent). The revision below should work if my assumption is correct. For Each ws In Worksheets ' ws.Activate For Each ws.query In QueryTables ws.query.Refresh BackgroundQuery:=False Next Next For Each query In ws.QueryTables query.Refresh False Next query ? -- Dick Kusleika MVP - Excel Excel Blog - Daily Dose of Excel www.dicks-blog.com |
Refreshing Query Tables
Yep, went brain dead for a minute.
Thanks for the correction. -- Regards, Tom Ogilvy "Dick Kusleika" wrote in message ... "Tom Ogilvy" wrote in message ... Suspect this is in a sheet module in which case, the unqualified references will remain pointed at the sheet containing the module rather than the activesheet (which is your intent). The revision below should work if my assumption is correct. For Each ws In Worksheets ' ws.Activate For Each ws.query In QueryTables ws.query.Refresh BackgroundQuery:=False Next Next For Each query In ws.QueryTables query.Refresh False Next query ? -- Dick Kusleika MVP - Excel Excel Blog - Daily Dose of Excel www.dicks-blog.com |
All times are GMT +1. The time now is 08:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com