title: Selecting Excel range throwing 1004 error in MS Access VBA
body: <p>I have a procedure that receives a file name and opens the file to copy a range of data into an Access database.</p>
  <p>It works if I run it one file at a time.</p>
  <p>When I pass it a second file it throws</p>
  <blockquote>
  <p>Method 'Range' of object'_Global' failed.</p>
  </blockquote>
  <p>If I close and start again it is fine.</p>
  <p>I have read a other questions about this error and tried different things.</p>
  <p>I validated there isn't anything different in any of the files. I ran it on at least 15 files one at a time and one-by-one they run fine. I tried calling the range in different ways, using Select instead of range, etc.</p>
  <p>I tried it in both Access 2010 and Access 2016.</p>
  <p>The error happens right after the &gt;&gt;&gt; PROBLEM HERE line below.</p>
  <pre><code>Dim appExcel As Excel.Application
  Dim myWorkbook As Excel.Workbook
  Dim mysheet As Excel.Worksheet
  
  Set appExcel = CreateObject(&quot;Excel.Application&quot;)
  Set myWorkbook = appExcel.Workbooks.Open(vfilepath &amp; &quot;\&quot; &amp; vfilename)
  appExcel.Visible = True
      
  With appExcel
  
      With appExcel.Worksheets(&quot;Sheet1&quot;).Activate
  
          ' &gt;&gt;&gt; PROBLEM HERE
          Worksheets(&quot;Sheet1&quot;).Range(&quot;B2&quot;, Range(&quot;N2&quot;).End(xlDown)).Select
  
          Selection.Copy
      End With
  
      DoCmd.OpenTable &quot;tblExcelImport_Main&quot;, acViewNormal
      DoCmd.RunCommand acCmdPasteAppend
      DoCmd.Close acTable, &quot;tblExcelImport_Main&quot;, acSaveYes
  
      myWorkbook.Close
      appExcel.Quit
      Set appExcel = Nothing
      Set myWorkbook = Nothing
      rst.Close
      cnn.Close
      
  End With
  End If
  </code></pre>
  <p>I need to loop through each file until finished (about 25 files - none are huge).</p>