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.
I get a run-time error 438 on my copy/paste line.
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("Enter name of file")
'open CSV file
zOpenFileName = Application.GetOpenFilename
'error handling
If zOpenFileName = "" Then Exit Sub
Application.ScreenUpdating = False
Set thisWB = ThisWorkbook 'destination workbook
Set thisWS = Sheets("f_dump") 'destination worksheet
Set thatWB = Workbooks.Open(zOpenFileName) 'source CSV
Set thatWS = thatWB.Sheets(inputData) 'source worksheet
Application.CutCopyMode = False
thatWB.thatWS.Range("A1:G150").Copy Destination:=thisWB.thisWS.Range("A1")
thatWB.Close
End Sub