It this what you wnat?
Sub ReadData()
Const ForReading = 1
filetoopen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If filetoopen = False Then
MsgBox ("Cannot open file - Exiting Macro")
Exit Sub
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(filetoopen, ForReading, False)
RowCount = 0
Do While f.AtEndOfStream < True
InputLine = f.ReadLine
If InStr(InputLine, "$ELEMENT ID") 0 Then
'remove ending of line
InputLine = _
Left(InputLine, InStr(InputLine, "IDENTIFIED BY TIME") - 1)
InputLine = Trim(InputLine)
If RowCount = 0 Then
RowCount = 1
Else
RowCount = RowCount + 3
End If
Range("A" & RowCount) = InputLine
Else
RowCount = RowCount + 1
'put data into array around spaces
Set MyArray = Nothing
MyArray = Split(InputLine, " ")
'test if it is a continue line
If MyArray(0) = "-CONT-" Then
StartCount = 1
Else
StartCount = 0
End If
ColCount = 1
For Index = StartCount To UBound(MyArray)
Cells(RowCount, ColCount) = MyArray(Index)
ColCount = ColCount + 1
Next Index
End If
Loop
f.Close
End Sub
--
joel
------------------------------------------------------------------------
joel's Profile:
http://www.thecodecage.com/forumz/member.php?userid=229
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=158475
Microsoft Office Help