I would do like this
Sub test()
Dim myDir As String, fn As String, t As Long, x
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show Then myDir = .SelectedItems(1) & "\"
End With
If myDir = "" Then Exit Sub
fn = Dir(myDir & "*.txt")
Do While fn <> ""
If FileLen(myDir & fn) Then
x = Split(CreateObject("Scripting.FileSystemObject") _
.OpenTextFile(myDir & fn).ReadAll, vbNewLine)
t = t + 1
Cells(1, t).Value = fn
Cells(2, t).Resize(UBound(x) + 1).Value = Application.Transpose(x)
End If
fn = Dir
Loop
End Sub
Bookmarks