View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
ward376 ward376 is offline
external usenet poster
 
Posts: 360
Default Query Tables naming not going to plan...

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