I'm using Excel 2016, and my WorkBook has several Queries connected to a SQL database in a server.
I am refreshing all the connections of my workbook using the following code:
For Each objConnection In ThisWorkbook.Connections
objConnection.Refresh
Next
And then I update a cell with the latest date that it was updated with the following:
worksheetControl.Range("UpdateDate") = Format(Now(), "yyyy-MM-dd")
But sometimes Refresh fails because of a bad internet connection, VPN not properly set, or something else. So in this case I wouldn't want to update my cell.
How can I check if my Refresh was successful for all the connections?
The solution provided should use the method RefreshAll instead. Because it is faster than iterating over each connection, so it would be the preferred method.