Refresh some not Refresh All

P

PBISMaryland

Hello. I have a workbook with 10 sheets all of which have external data that
needs to be refreshed periodically. Most of the time I only need to refresh
8 of the sheets. Is there a way to refresh just those 8 without having to
refresh each one separately?
Thanks in advance.
 
J

Jim Thomlinson

You can use a macro to do it. It would go something like this...

Sub RefreshSome()
Dim wks As Worksheet
Dim qt As QueryTable

For Each wks In Worksheets
Select Case wks.Name
Case "Sheet1", "sheet2"
Case Else
For Each qt In wks.QueryTables
qt.Refresh
Next qt
End Select
Next wks

End Sub

the above will refresh all querytables in all sheets excpet for sheet1 and
sheet2
 

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

Top