title: Excel/Access VBA - Cant get last used row because of query refresh
body: <p>I'm refreshing a query on Access and looping over the table, but the loop overruns the refresh - so I dont get the correct last row.</p>
  
  <p>After refreshing, <strong>a</strong> should equal 2746, but it's returning 1478 which is the last row before refreshing.</p>
  
  <pre><code>vPath = ThisWorkbook.Sheets(vHome).Range("LogTblFolder")
  vFile = ThisWorkbook.Sheets(vHome).Range("LogTblFile")
      Set wb = Workbooks.Open(vPath &amp; vFile)
  
          Sheets("Main").Select
          ActiveWorkbook.Connections("CTA_DB_Full3").Refresh
          ActiveWorkbook.Connections("CTA_DB_Full3").Refresh
  
              Call WaitForRefresh(1)
              a = 1:Do Until Sheets("Main").Cells(a, 1).Value2 = "":a = a + 1:Loop
                    vArray = Sheets("Main").Range(Cells(2, 1), Cells(a, 94))
  
      wb.Close False
  </code></pre>
  
  <hr>
  
  <pre><code>Public Function WaitForRefresh(intSeconds As Integer)
  Dim dblStart As Double
  
  If intSeconds &gt; 0 Then
  
      dblStart = Timer()
  
      Do While Timer &lt; dblStart + intSeconds
      Loop
  
  End If
  End Function`
  </code></pre>
  
  <p>Help is much appreciated!!!</p>