<p>I had the same issue with an OLEDBConnection connection type, however <code>DoEvents</code> (as suggested in a prior answer) didn’t help me as my data connections had background-refresh enabled. Instead, using <a href="https://stackoverflow.com/users/2895550/wayne-g-dunn">Wayne G. Dunn</a>’s <a href="https://stackoverflow.com/questions/22083668/how-to-wait-until-activeworkbook-refreshall-finishes-before-executing-more-code/22085922#22085922">answer</a> as a jumping-off point, I created the following solution, which worked:</p>
<pre><code class="lang-auto">Sub Refresh_All_Data_Connections()
For Each objConnection In ThisWorkbook.Connections
'Get current background-refresh value
bBackground = objConnection.OLEDBConnection.BackgroundQuery
'Temporarily disable background-refresh
objConnection.OLEDBConnection.BackgroundQuery = False
'Refresh this connection
objConnection.Refresh
'Set background-refresh value back to original value
objConnection.OLEDBConnection.BackgroundQuery = bBackground
Next
MsgBox "Finished refreshing all data connections"
End Sub
</code></pre>
<p>The <strong>MsgBox</strong> is for testing only and can be removed once you’re happy the code waits.</p>
<p>Also, I prefer <strong>ThisWorkbook</strong> to <strong>ActiveWorkbook</strong> as I know it will target the workbook where the code resides, just in case focus changes. Nine times out of ten this won’t matter, but I like to err on the side of caution.</p>
<p>However, note that because this uses <code>BackgroundQuery</code>, this will not work if you are using an <code>xlConnectionTypeXMLMAP</code> connection, sorry.</p>