Query Tables naming not going to plan...
Ward - thanks for the response however it's pretty much the same as Joel's
answer of looping through each name and trying to find my partiular query. My
problem comes about because Excel insists on appending "_1" to my query name
so I can't access it directly...for instance I can't be sure that it won't be
"_2" - other than relying on my coding genius of course :-)
As I replied to Don, I've used Joel's suggestion (and this one really) of
looking through each query table to find "mine" (with the "_1") and then just
refreshed that particular query. Not elegant by any stretch of the
imagination, but hey-ho...move on and get on with something else I say!
Thanks for all the response, consider this matter closed for the
moment...unless anyone has an answer for why Excel appends this rubbish on my
query name. Something peculiar to 2003 for instance?
George
"ward376" wrote:
Have you tried testing for part of the qt name?
Sub qtRefresh()
Dim ws As Worksheet
Dim qt As QueryTable
For Each ws In Sheets(Array(Sheet1.Name, Sheet2.Name))
If ws.QueryTables.Count 0 Then 'this may help also
For Each qt In ws.QueryTables
If LCase(Left(qt.Name, 9)) = LCase("PDEngland") Then
qt.Refresh BackgroundQuery:=False
Else
'create a query
End If
Next qt
End If
Next ws
End Sub
Cliff Edwards
|