The OP parameter is ambiguous: the text asks to update all the query tables on the active sheet, but the sample code updates only one query table containing cell B3
To update only one query table, use
Sub RefreshOneQuery() Dim qt As QueryTable On Error Resume Next ' in case there is no qt containing cell B6 Set qt = Range("B6").QueryTable On Error GoTo 0 If Not qt Is Nothing Then qt.Refresh BackgroundQuery:=False End If End Sub
To update all query tables in a worksheet, use
Sub RefreshAllQueries() Dim qt As QueryTable For Each qt In ActiveSheet.QueryTables qt.Refresh BackgroundQuery:=False Next End Sub
source share