title: Use SQL to combine files from different locations in Excel
body: <p>I am trying to combine different files from different file locations into one spread sheet. I find some code online through which I was able to use SQL in VBA to combine them if they are from the same location:</p>
  
  <p>Excerpt of the code is here:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Sub sample()
  
      Set objConnection = CreateObject("ADODB.Connection")
      Set objRecordSet = CreateObject("ADODB.Recordset")
  
      objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" &amp; _
      "Data Source=" &amp; ThisWorkbook.path &amp; ";" &amp; _
      "Extended Properties=""text;HDR=YES;FMT=Delimited"""
  
      StrSQL="SELECT * FROM samplesheet.csv"
  
      objRecordSet.Open StrSQL
  
  ...
  
  End Sub
  </code></pre>
  
  <p>In my code above I can specify only one location as Data Source. Is there any other way to write the SQL code so it can work with multiple locations?</p>
  
  <p>Thanks</p>