Question: I have one folder with multiple text files that I add one text file to every day. All text files are in the same format and are pipe delimited. 

Is it possible to create code for excel that will automatically import the data from the multiple text files into one worksheet?

I found some code that would import all the text files from the folder, but only if I changed it all to comma delimited first. Also, I could not get it to update if I added files to the folder. 

Any help would be greatly appreciated!

Answer: 
A good way to handle files in general is the 'FileSystemObject'. To make this available in VBA you need to add a reference to it:

(select the Tools\References menu. In the References dialog, select 'Microsoft Scripting Runtime')

The following code example will read all files in a folder, reads their content one line at a time, split each line into | separated bits, and writes theses bits to the active sheet starting at cell A1, one row per line.

```
Sub ReadFilesIntoActiveSheet()
    Dim fso As FileSystemObject
    Dim folder As folder
    Dim file As file
    Dim FileText As TextStream
    Dim TextLine As String
    Dim Items() As String
    Dim i As Long
    Dim cl As Range

    ' Get a FileSystem object
    Set fso = New FileSystemObject

    ' get the directory you want
    Set folder = fso.GetFolder("D:\YourDirectory\")  

    ' set the starting point to write the data to
    Set cl = ActiveSheet.Cells(1, 1)

    ' Loop thru all files in the folder
    For Each file In folder.Files
        ' Open the file
        Set FileText = file.OpenAsTextStream(ForReading)

        ' Read the file one line at a time
        Do While Not FileText.AtEndOfStream
            TextLine = FileText.ReadLine

            ' Parse the line into | delimited pieces
            Items = Split(TextLine, "|")

            ' Put data on one row in active sheet
            For i = 0 To UBound(Items)
                cl.Offset(0, i).Value = Items(i)
            Next

            ' Move to next row
            Set cl = cl.Offset(1, 0)
        Loop

        ' Clean up
        FileText.Close
    Next file

    Set FileText = Nothing
    Set file = Nothing
    Set folder = Nothing
    Set fso = Nothing

End Sub

```

the sub is deliberately simplified to remain clear (i hope) and will need work to be made robust (eg add error handling)
You can use Schema.ini ( <http://msdn.microsoft.com/en-us/library/ms709353(VS.85).aspx> ), Jet driver and Union query, with any luck.