Forum Discussion
jaymcgary
Aug 11, 2022Copper Contributor
Importing Text File into specific cell range using VBA
Hi all, appreciative for any help. I am using the following code to import a text file created via PowerShell. Except, I cannot seem to select a specific range of cells for the import to happen a...
JKPieterse
Aug 11, 2022Silver Contributor
This line is wrong:
wbText.Sheets(1).Cells.Copy wsExcel.Cells
it should read something like:
wbText.Sheets(1).UsedRange.Cells.Copy wsExcel.Cells(1,1)
(note I've added the UsedRange object to the left side to limit what's copied to the actual data)
wbText.Sheets(1).Cells.Copy wsExcel.Cells
it should read something like:
wbText.Sheets(1).UsedRange.Cells.Copy wsExcel.Cells(1,1)
(note I've added the UsedRange object to the left side to limit what's copied to the actual data)