Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Query Refresh code

Try this :

Private Sub CommandButton1_Click()
Dim WS As Worksheet
Dim QT As QueryTable

For Each WS In Worksheets
'WS.Activate No need
For Each QT In WS.QueryTables
QT.Refresh BackgroundQuery:=False
Next 'QT
Next

End Sub

NickHK

"SthOzNewbie" wrote in message
...
I know next to nothing about VB programming so please excuse any obvious
errors in the following -

I am trying to refresh multiple querytables using a button. I grabbed the
code from another post so I may not have the full context -

Private Sub CommandButton1_Click()

For Each ws In Worksheets
ws.Activate
For Each query In ws.QueryTables
query.Refresh BackgroundQuery:=False
Next query
Next

End Sub

I get an error "application defined or object defined error". What do I

need
to do to fix this ?

TIA

IK



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I 'Enable Automatic Refresh' for Query Refresh by default Anand Deshpande Setting up and Configuration of Excel 0 December 10th 06 04:47 AM
Code To Refresh Query Table Carl Excel Discussion (Misc queries) 0 December 8th 06 01:23 AM
Query Refresh-Enable Automatic Refresh Dialogue Box Terri Excel Discussion (Misc queries) 0 May 6th 05 08:21 PM
Timing of automatic query refresh and macro pivot table refresh dutty Excel Programming 2 December 1st 04 07:19 PM
Excel does not close from VB!! (when i refresh Refresh query with BackgroundQuery:=False) Anant[_2_] Excel Programming 1 August 6th 03 04:22 AM


All times are GMT +1. The time now is 07:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"