Here's my effort.
Sub ImportOutputFile()
Dim WS As Worksheet
Dim WSDest As Worksheet
Dim FN As String
Dim Path As String
Dim A$
Dim aRow As Long
Dim FF As Integer
Set WS = Worksheets("Tab1")
Set WSDest = Worksheets("Sheet2") 'Change as required.
Path = "C:\Users\Bob\Documents\TextFiles"
'Check if B4 is not blank
If WS.Range("B4") <> "" Then
'Build filename
FN = "Output" & [b4] & ".txt"
'Does path and filename exist?
If Dir(Path & "\" & FN) <> "" Then
'Assign next available filenumber
FF = FreeFile
'OPen file for reading
Open FN For Input As #FF
With WSDest
'Delete all previous data
.Cells.Delete
'Read the first line
Line Input #1, A$
'Assign first row number.
aRow = 1
'Input into cell.
.Cells(aRow, 1) = A$
'Loop util end of file.
Do Until EOF(1)
'Incfrement row number
aRow = aRow + 1
'Repeat
Line Input #1, A$
.Cells(aRow, 1) = A$
Loop
End With
'Close file
Close #1
End If
End If
End Sub
Bookmarks