Open CSV and copy
<p>I'm trying to open a CSV file (generated daily from another program) and copy the data into a certain sheet in my current workbook.</p>
<p>I get a run-time error 438 on my copy/paste line.</p>
<pre class="lang-vb prettyprint-override"><code>Sub GetCSV()

    Dim thatWB As Workbook, thisWB As Workbook
    Dim thisWS As Worksheet, thatWS As Worksheet
    Dim zOpenFileName As String
    Dim inputData As String

    'get name of sheet to open
    inputData = InputBox(&quot;Enter name of file&quot;)

    'open CSV file
    zOpenFileName = Application.GetOpenFilename
   
    'error handling
    If zOpenFileName = &quot;&quot; Then Exit Sub

    Application.ScreenUpdating = False

    Set thisWB = ThisWorkbook 'destination workbook
    Set thisWS = Sheets(&quot;f_dump&quot;) 'destination worksheet
    
    Set thatWB = Workbooks.Open(zOpenFileName) 'source CSV
    Set thatWS = thatWB.Sheets(inputData) 'source worksheet

    Application.CutCopyMode = False

    thatWB.thatWS.Range(&quot;A1:G150&quot;).Copy Destination:=thisWB.thisWS.Range(&quot;A1&quot;)

    thatWB.Close
         
End Sub
</code></pre>