(Solved) – Query refresh in sequence, let the first query finish before refreshing the next one

(solved)-–-query-refresh-in-sequence,-let-the-first-query-finish-before-refreshing-the-next-one
Dim con As WorkbookConnection
For Each con In ThisWorkbook.Connections
    If InStr(1, con.Name, "Query -") Then
        With con.OLEDBConnection
            .BackgroundQuery = False
            .Refresh
        End With
    End If
Next
End Sub

The code refreshes the queries in sequence but doesn’t wait until the first query is finished, causing the queries to get stuck. I am stuck on how to make the queries finish and then go to the next one in the sequence in the workbook.

Leave a Reply

Your email address will not be published. Required fields are marked *