title: Working with Query Table in Excel/VBA
body: <p>I am getting a "Subscript out of Range" Error 9 with my code. I have a Microsoft Access database connected to Excel and a table already made with the Query for Table "QUERY_1". I want to update the table with "QUERY_2" through using VBA. The error occurs on this line:</p>
  
  <pre><code>Set QueryARV = QuerySheet.QueryTables(1)
  </code></pre>
  
  <p>Here is the full procedure:</p>
  
  <pre><code>Sub ChooseQueryTable()
  
  Dim QueryARV As QueryTable
  Dim QuerySheet As Worksheet
  
  Set QuerySheet = ThisWorkbook.Sheets("Sheet1")
  Set QueryARV = QuerySheet.QueryTables(1)
  
  With QueryARV
  .CommandType = xlCmdTable
  .CommandText = "QUERY_1"
  .Refresh
  End With
  
  End Sub
  </code></pre>