LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Refresh Queries in All Worksheet

Thanks Joel...the debug qry worked...and you were correct, I had an invalid
query. I've fixed the query and applied the second macro and now my
spreadsheet works great. Thanks again.

Joel wrote:
The second macro should work since you get an error it must mean the query
is corrupted. Probaly the source data file doesn't exist or the table in the
database no longer exists. Yo have to find which queries don't work and
delete these queries.

Go to menu
Insert Names Define

All the queries should be listed as a named range. Yo need to remove from
the name range table the invalid queries. the code below should help you
find all the queries.

Sub DebugQuery()
Dim WS As Worksheet
Dim QT As QueryTable

Sheets.Add after:=Sheets(Sheets.Count)
Set Sht = ActiveSheet
With Sht
.Name = "Debug"
.Range("A1") = "Sheet Name"
.Range("B1") = "Row"
.Range("C1") = "Column"
.Range("D1") = "Connection"
.Range("E1") = "Command Text"

RowCount = 2
End With

For Each WS In ActiveWorkbook.Worksheets
If WS.Name < "Debug" Then
With WS
For Each QT In .QueryTables
Sht.Range("A" & RowCount) = .Name
Sht.Range("B" & RowCount) = QT.ResultRange.Row
Sht.Range("C" & RowCount) = QT.ResultRange.Column
Sht.Range("D" & RowCount) = QT.Connection
Sht.Range("E" & RowCount) = QT.CommandText
RowCount = RowCount + 1
'QT.Refresh
Next QT
End With
End If
Next WS
End Sub

Hi all,
Need some help on an excel project I've been tasked with. I have an excel

[quoted text clipped - 47 lines]
in left field?
Any help is appreciated. Thanks!!!!


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200908/1

 
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
SPSS QUeries in Excel and refresh data mike b Excel Discussion (Misc queries) 0 April 3rd 08 09:48 PM
I cannot refresh all of the queries in my spreadsheet Peter Excel Discussion (Misc queries) 0 July 25th 06 04:23 PM
Refresh Data - Database Queries tpearo Excel Programming 0 June 27th 06 06:34 PM
Refresh Multiple Queries via a Command Button Dmorri254 Excel Programming 2 February 27th 06 03:45 PM
Refresh queries, graphs, and charts Fredrik Wahlgren Excel Discussion (Misc queries) 1 April 1st 05 08:29 PM


All times are GMT +1. The time now is 12:25 PM.

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

About Us

"It's about Microsoft Excel"