title: VBA: microsoft access database engine could not find the object (SQL query worksheet table)
body: <p>I am getting the following error message, on the line  <code>rs.Open strSQL, cn</code> , when trying to do a SQL select statement against a table range in an Excel spreadsheet:</p>
  
  <blockquote>
    <p>The Microsoft Access database engine could not find the object
    'Sheet1$A1:NC3'. Make sure the object exists and that you spell its
    name and the path name correctly. If 'Sheet1$A1:NC3' is not a local
    object, check your network connection or contact the server
    administrator</p>
  </blockquote>
  
  <p>I have run through the various Stack Overflow side bar suggestions for similar questions, and let Google have a run at it, but i have still not resolved this.</p>
  
  <ol>
  <li><p>The object is local - check</p></li>
  <li><p>Workbook is the current open workbook which is saved to the desktop -check</p></li>
  <li><p>Network connection fine - check</p></li>
  </ol>
  
  <p><strong>Observations</strong></p>
  
  <ol>
  <li><p>Putting the SQL string as <code>"Select * from [Sheet1$];"</code> works fine.</p></li>
  <li><p>Extend that, by adding the range reference, and the error comes back i.e. <code>"Select * from [Sheet1$A1:NC3];"</code> does not work.</p></li>
  <li><p>As noted in comments, up to column IV i.e. <code>[Sheet1$A1:IV3]</code> is ok; column IW onward, and error message is back.</p></li>
  </ol>
  
  <p><strong>Note</strong>: <code>Debug.Print</code> confirms</p>
  
  <ol>
  <li><p><code>ListObjects("Table1").Range.Address</code> as <code>$A$1:$NC$3</code> </p></li>
  <li><p><code>rngAddress</code> is <code>[Sheet1$A1:NC3];</code></p></li>
  </ol>
  
  <p>Can anyone please spot what i have done incorrectly? Or suggest a workaround so i can still use this range (and preferably <strong>not</strong> select the entire sheet)</p>
  
  <p>Here is the full code:</p>
  
  <pre><code>Option Explicit
  
  
  Public Sub TestSQL()
      'Tools &gt; references &gt; Microsoft ActiveX Object Library
  
      Dim wb As Workbook
      Dim wsSource As Worksheet
      Dim strFile As String
      Dim strCon As String
      Dim strSQL As String
  
      Set wb = ThisWorkbook
      Set wsSource = wb.Worksheets("Sheet1")
  
      Dim cn As ADODB.Connection
      Dim rs As ADODB.Recordset
  
      strFile = ThisWorkbook.FullName
      strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" &amp; strFile _
             &amp; ";Extended Properties=""Excel 12.0;HDR=Yes;IMEX=1"";"
  
      Set cn = CreateObject("ADODB.Connection")
      Set rs = CreateObject("ADODB.Recordset")
  
      cn.Open strCon
  
      Dim rngAddress As String
  
      rngAddress = "[" &amp; wsSource.Name &amp; "$" &amp; Replace(wsSource.ListObjects("Table1").Range.Address, "$", "") &amp; "];"
  
      strSQL = "SELECT * FROM " &amp; rngAddress
  
      rs.Open strSQL, cn
  
  End Sub
  </code></pre>
  
  <p>Environment: Windows 8, Excel 2016 64 bit.</p>