Hello all,
I have multiple multi-line text files that I am trying to import into one sheet. I would like each text file to have its own column.
Thus far, I have successfully pulled them all in to one column using the code that user patel45 posted here:
Sub readTxtFiles()
Dim folderPath As String, Filename As String, WB As Workbook
folderPath = "C:\test\" ' <<<< folder of text files (to be changed)
Filename = Dir(folderPath & "*.txt")
drow = 2 ' <<< initial destination row
Do While Filename <> ""
sn = Split(CreateObject("scripting.filesystemobject").opentextfile(folderPath & Filename).readall, vbCrLf)
For j = 0 To UBound(sn)
Cells(j + drow, 1) = sn(j)
Next
drow = drow + j
Filename = Dir
Loop
End Sub
Would anyone be able to help me figure out what to add to this code to make each text file have its own column?
Thank you in advance! (And thank you to patel45 for at least getting me started in the right direction.)
Bookmarks