Macro to update all queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top