title: Export data from Excel to Access - Error: Argument not Optional
body: <p>I'm trying to export data from Excel 2010 to Access 2010 with a VBA code on my excel file when I press a button. I just want to export the data from "Water Quality" sheet to the "Water Quality" table on my database (In the excel file and access file are other sheets and tables).</p>
  
  <p>My actual code is:</p>
  
  <pre><code>Sub Button14_Click()
  
  ' Exports data from the active worksheet to a table in an Access database
  
  Dim cn As ADODB.Connection
  Dim rs As ADODB.Recordset
  Dim r As Long
  Dim LastRow As Long
  
  ' Set cn = New ADODB.Connection
  
  'cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " &amp; _
      "Data Source=C:\Documents and Settings\Administrador\Mis documentos\MonEAU\modelEAU Database V.2.accdb; " &amp; _
      "Persist Security Info=False;"
  
  strCon = "Provider=Microsoft.ACE.OLEDB.12.0; " &amp; _
      "Data Source=C:\Documents and Settings\Administrador\Mis documentos\MonEAU\modelEAU Database V.2.accdb"
  
  ' Late binding, so no reference is needed
  Set cn = CreateObject("ADODB.Connection")
  
  cn.Open strCon
  
  ' Find LastRow in Col A into the Sheet1
  LastRow = Sheet1.Range("A" &amp; Rows.Count).End(xlUp).Row
  
  ' Insert unto a table called Water_Quality
  scn = "[Excel 8.0;HDR=YES;DATABASE=" &amp; ActiveWorkbook.FullName &amp; "]"
  strSQL = "INSERT INTO Water_Quality " _
         &amp; "SELECT * FROM " &amp; scn &amp; ".[Sheet1$A5:L" &amp; LastRow &amp; "]"
  
  ' Execute the statement
  cn.Execute strSQL
  
  rs.Close
  cn.Close
  Set rs = Nothing
  Set cn = Nothing
  
  End Sub
  </code></pre>
  
  <p>I can debug without any problem the code but when I run it, a run error appears: "The Microsoft Office Access database engine could not find the object 'Sheet1$A5:L10'. Make sure the object exists and that you spell its name and the path name correctly." It seems that there's a problem with the line <code>cn.Execute strSQL</code>.</p>
  
  <p>I've checked the names and the path name as well, and I can't find where the problem is.</p>
  
  <p>Any help to solve it would be greatly appreciated.</p>