Import Multiple .log files into columns?

hansocool

New Member
Joined
May 31, 2011
Messages
12
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.

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
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top