I'm trying to import a folder of .log files, one into each column (the log files are each just one column long).
Here's what I have so far. I get an "out of memory" at the Cells(r, c) = Fdata.
Here's what I have so far. I get an "out of memory" at the Cells(r, c) = Fdata.
Code:
Sub Combine()
Dim r As Long
Dim c As Long
Dim Fpath As String
Dim Fname As String
Dim Fdata As String
Fpath = "C:\Users\" ' change to suit your directory
If Right(Fpath, 1) <> "\" Then Fpath = Fpath & "\"
Fname = Dir(Fpath & "*.log")
Sheet1.Cells.ClearContents
Do While Fname <> ""
c = c + 1
Open Fpath & Fname For Input As #1
Do Until EOF(1)
'Limit the importing to the first 21 columns of the workbook (can be deleted if each text file contains no more than 21 rows of data)
r = r + 1
Input #1, Fdata
Cells(r, c) = Fdata
Loop
Close #1
r = 0
Fname = Dir
Loop
End Sub