5
Friends、 CSVファイル(毎日別のプログラムから生成)を毎日開き、CSVシートのデータを現在のワークブックの特定のシートにコピーしようとしています。私はしばらくの間、このコードを作業して、それは本当に近くにあると思うが、私はコピー/貼り付け行に実行時エラー438を得続けている。どんな助け?CSVとコピーを開く
ありがとうございました!ここで
は私のコードです:
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
、直接コピーも確信していません'thisWS.Range(" A1:G150 ")。コピー先:= thisWS.Range(" A1 ")' PasteSpecial'メソッドも有効です。それだけでは必要ありません。 –
ありがとうございます。どちらのソリューションも正しく動作します。私はLubosを正しいとマークしましたが、Scottの作品も同様です。 – tulanejosh