title: How Can I Speed Up An ADODB Connection
body: <p>I am running the code below to retrieve data from my Access Database into Excel. The code takes about 1 minute to execute. There are currently about 500 records with 8 columns. Is there anything I can do to modify my code to run faster?</p>
  
  <pre class="lang-vb prettyprint-override"><code>Sub sync_Data()
      Application.ScreenUpdating = False
      Application.EnableEvents = False
      Application.Calculation = xlCalculationManual
  
      Dim cn As ADODB.Connection, rs As ADODB.Recordset
      Dim mysqlSt As String
      Dim rowindex As Long
  
      mysqlSt = "SELECT pbsclients.client, pbsclients.priority, pbsclients.source, pbsclients.lastcontact, pbsclients.result, pbsclients.nextsteps, pbsclients.attempts, pbsclients.notes FROM pbsclients; "
  
      Set cn = New ADODB.Connection
      With cn
          .ConnectionString = con1
          .Open
      End With
  
      rowindex = 2
      Set rs = New ADODB.Recordset
      rs.Open mysqlSt, cn, adOpenDynamic, adLockOptimistic
  
      While Not rs.EOF
          Sheet3.Cells(rowindex, 1) = rs!client
          Sheet3.Cells(rowindex, 2) = rs!Priority
          Sheet3.Cells(rowindex, 3) = rs!Source
          Sheet3.Cells(rowindex, 4) = rs!lastcontact
          Sheet3.Cells(rowindex, 5) = rs!result
          Sheet3.Cells(rowindex, 6) = rs!nextsteps
          Sheet3.Cells(rowindex, 7) = rs!attempts
          Sheet3.Cells(rowindex, 8) = rs!Notes
  
          rowindex = rowindex + 1
          rs.MoveNext
      Wend
  
      rs.Close
      Set rs = Nothing
      cn.Close
      Set cn = Nothing
      Exit Sub
  
      Application.ScreenUpdating = True
      Application.EnableEvents = True
      Application.Calculation = xlCalculationAutomatic
  End Sub
  </code></pre>