Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default External data queries within applcation collection

Hi,

I have a workbook with many sheets and approx. 10 of these sheets
query data from an Acc97 db. I have some vba code that executes a
'RefreshAll', but this doesn't always seem to work ?????

I'd like to cycle through each one seperately and assume there is a
reference to each query in the Application collection but I can't find
it.

If it exists I assume I can set up a loop, based on the number of
queries in the workbook and refresh each one individually? which I
think means I won't need to make any changes to this code if the
number of queries change ?

A link to a website explaining this, or an appropriate keyword to
enter in to Excel help would be great.

Many thanks in advance of a helpful reply,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default External data queries within applcation collection

The following code refreshes each query in the active workbook:

Sub MyQueries()
Dim qry As QueryTable
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
For Each qry In ws.QueryTables
qry.Refresh
Next qry
Next ws
End Sub


Andy S wrote:
Hi,

I have a workbook with many sheets and approx. 10 of these sheets
query data from an Acc97 db. I have some vba code that executes a
'RefreshAll', but this doesn't always seem to work ?????

I'd like to cycle through each one seperately and assume there is a
reference to each query in the Application collection but I can't find
it.

If it exists I assume I can set up a loop, based on the number of
queries in the workbook and refresh each one individually? which I
think means I won't need to make any changes to this code if the
number of queries change ?

A link to a website explaining this, or an appropriate keyword to
enter in to Excel help would be great.

Many thanks in advance of a helpful reply,



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default External data queries within applcation collection

Debra,

Thanks for a perfect example of good code.....



Debra Dalgleish wrote in message ...
The following code refreshes each query in the active workbook:

Sub MyQueries()
Dim qry As QueryTable
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
For Each qry In ws.QueryTables
qry.Refresh
Next qry
Next ws
End Sub


Andy S wrote:
Hi,

I have a workbook with many sheets and approx. 10 of these sheets
query data from an Acc97 db. I have some vba code that executes a
'RefreshAll', but this doesn't always seem to work ?????

I'd like to cycle through each one seperately and assume there is a
reference to each query in the Application collection but I can't find
it.

If it exists I assume I can set up a loop, based on the number of
queries in the workbook and refresh each one individually? which I
think means I won't need to make any changes to this code if the
number of queries change ?

A link to a website explaining this, or an appropriate keyword to
enter in to Excel help would be great.

Many thanks in advance of a helpful reply,

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
Excel Inport External Data - new queries Lozza65 Excel Worksheet Functions 1 November 26th 07 10:55 AM
Excel 2002 External Data Queries and UNC !HELP! KayC Excel Discussion (Misc queries) 0 April 23rd 07 10:33 AM
External Data Queries - Data Range Properties v Spreadsheet Format HLS Excel Discussion (Misc queries) 0 April 5th 06 11:09 AM
Excel 2003 This Workbook contains queries to external data Puzzled of Springburn Excel Discussion (Misc queries) 0 February 8th 05 03:21 PM
How do I pull multiple queries of external data from the Internet into Excel? JSD Excel Programming 1 September 22nd 03 11:24 PM


All times are GMT +1. The time now is 02:39 AM.

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"