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
|