Loop through excel files in a directory and copy onto master sheet
<p>I have a folder with nearly 1000 .csv files. Each of these files contains 2 columns, and I would like to copy only one of these columns and transpose it onto a new workbook. The new workbook will contain all the data from each of these files. The following code is what I have generated:</p>

<pre><code>    Sub AllFiles()
    Application.EnableCancelKey = xlDisabled

    Dim folderPath As String
    Dim Filename As String
    Dim wb As Workbook

    folderPath = "J:etc. etc. etc." 'contains folder path

    If Right(folderPath, 1) &lt;&gt; "\" Then folderPath = folderPath + "\"

    Filename = Dir(folderPath &amp; "*.csv")
    Do While Filename &lt;&gt; ""
      Application.ScreenUpdating = False
        Set wb = Workbooks.Open(folderPath &amp; Filename)

        wb.Range(Range("B1"), Range("B1").End(xlDown)).Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveWorkbook.Close True
        Windows("Compiled.xlsm").Activate
        Worksheets("Sheet1").Range("A" &amp; Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True

        Filename = Dir
    Loop
  Application.ScreenUpdating = True
End Sub
</code></pre>

<p>For whatever reason the code does not work and a box pops-up saying "Code execution has been interrupted." Once I hit "Debug" the following line is highlighted:</p>

<pre><code>wb.Range(Range("B1"), Range("B1").End(xlDown)).Select
</code></pre>

<p>I am not experienced with VBA at all and I am having trouble troubleshooting this issue. Any idea on what this means and what I can do?</p>