Experts Exchange connects you with the people and services you need so you can get back to work.
Dim vFF As Long, vFiles As Variant, vFile As Variant, FileCont(), filecnt As Long, i As Long
Dim vDelim As String, vRow As Long
vFiles = Application.GetOpenFilename("Text Files,*.txt;*.csv,All Files,*.*", MultiSelect:=True)
If LCase(vFiles(1)) = "false" Then Exit Sub 'hit cancel
vDelim = InputBox("What is the file delimiter? Enter blank for fixed width.", "Enter delimiter", ",")
filecnt = 0
ReDim FileCont(1, filecnt)
For Each vFile In vFiles
vFF = FreeFile
Open vFile For Input As #vFF
Do Until EOF(vFF)
Line Input #vFF, TempStr
ReDim Preserve FileCont(1, filecnt)
FileCont(0, filecnt) = vFile
FileCont(1, filecnt) = Split(TempStr, vDelim)
filecnt = filecnt + 1
filecnt = filecnt - 1
Application.ScreenUpdating = False
vRow = 1
For i = 0 To filecnt
Cells(vRow, 1) = FileCont(0, i)
Range(Cells(vRow, 2), Cells(vRow, UBound(FileCont(1, i)) + 2)) = FileCont(1, i)
vRow = vRow + 1
Application.ScreenUpdating = True
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!