ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to update all queries (https://www.excelbanter.com/excel-programming/394416-macro-update-all-queries.html)

Josh Johansen

Macro to update all queries
 
I need to write a macro that will refresh or update about 10 queries that are
on another sheet. Automatically updating it when the file is opened is not
what they want to have happen, can someone help me figure this out, I really
am not too sure, thanks.

Vergel Adriano

Macro to update all queries
 
Josh,

As an example, the code below will refresh all queries in a sheet named
"Sheet2".

Sub Test
Dim qry As QueryTable
For Each qry In Sheets("Sheet2").QueryTables
qry.Refresh BackgroundQuery:=True
Next qry
End Sub

--
Hope that helps.

Vergel Adriano


"Josh Johansen" wrote:

I need to write a macro that will refresh or update about 10 queries that are
on another sheet. Automatically updating it when the file is opened is not
what they want to have happen, can someone help me figure this out, I really
am not too sure, thanks.



All times are GMT +1. The time now is 04:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com