I have a macro that refreshes all my power query connections. After this is refreshed, the process quickly goes through each worksheet to apparently update the tables on each sheet. The problem is that I want to select the "Main" sheet after this refresh is done, but no matter what, the tables are updated as the last step. I've tried to call another macro to select the main sheet. I've also tried putting in the application.wait command. Nothing works. It always updates the tables last. Here's what I've got so far with the code...![]()
Sub PQ_Refresh() Dim lCnt As Long With ActiveWorkbook For lCnt = 1 To .Connections.Count If .Connections(lCnt).Type = xlConnectionTypeOLEDB Then .Connections(lCnt).OLEDBConnection.BackgroundQuery = False End If Next lCnt End With ActiveWorkbook.Connections("Query - CK Elevation").Refresh ActiveWorkbook.Connections("Query - AF Discharge").Refresh ActiveWorkbook.Connections("Query - AF nflow").Refresh ActiveWorkbook.Connections("Query - HP Elevation").Refresh ActiveWorkbook.Connections("Query - BD Discharge").Refresh ActiveWorkbook.Connections("Query - IN Elevation").Refresh ActiveWorkbook.Connections("Query - BC Discharge").Refresh Sheets("Main").Select End Sub
Bookmarks