1

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.

braX
  • 11,506
  • 5
  • 20
  • 33
Lorenzo C.
  • 11
  • 3
  • 1
    [This question](https://stackoverflow.com/questions/43548543/how-to-check-whether-connection-refresh-was-successful) might be helpful. – BigBen Nov 27 '18 at 18:56
  • Hey @BigBen, sorry but I don't have any **QueryTable** in my WorkBook. I have used the PowerQuery to bring the data, it's a different situation. I have tried that solution before, does not work. – Lorenzo C. Nov 27 '18 at 19:11
  • 1
    @BigBen can you uncheck the duplicate? – Lorenzo C. Nov 27 '18 at 19:34
  • I cannot, @Matthieu Guindon marked it as duplicate. – BigBen Nov 27 '18 at 19:35

0 Answers0