Hi
Following on from DavidCotts couts suggestion I have listed below a modified extract I have written to do just what you have indicated.
This is based on a form having two command buttons and a text box (you will also need to show the form).
Code:
Option Explicit
Private Sub CommandButton1_Click()
Dim File As String
ChDir ThisWorkbook.Path
File = Application.GetOpenFilename("Text Files (*.txt), *.txt", , "Select Text File")
If File = "False" Then Exit Sub
If Dir(File) = "" Then
MsgBox File & " Not found !"
Else
TextBox1 = File
End If
End Sub
Private Sub CommandButton2_Click()
Dim Text As String
If Dir(TextBox1) = "" Then
MsgBox File & "File Path & Name must be specied !"
Else
Open TextBox1 For Input As #1 ' OPEN FILE FOR READING
Line Input #1, Text ' READ FIRST LINE
If Text <> "??" Then
MsgBox "File not compatable etc"
Else
Do While Not EOF(FileNo)
'PARSE EACH FILE LINE HERE AND WRITE TO ACTIVE SHEET !!
Loop
End If
Close #1 'CLOSE FILE
End If
End Sub
As indicated, information is available in the VBA Help files for both GetOpenFileName and the Open Method for reading a file on disk one line at a time.
Of course we do not know what procedure you require to parse each line.
This code also relies on the first line odf the file having a unique id to verifiy it is the correct type of file to be parsed!
Just one way of doing it!
HTH
MTB