Hi Rocky
with out knowing the possible data layouts something like this
Sub ReadTxt()
Dim tmpCode, lastObj As String
Open "C:\ Your File Path \rocky text.txt" For Input As #1
Do While Not EOF(1)
Codes = ReadLines
xRow = xRow + 1
If Codes(0) <> "End_Of Line" Then
xCol = 1
For xcount = 1 To 5
For Each xValue In Split(Codes(xcount), " ")
If xValue <> "" Then
Cells(10 + xRow, xCol).Value = xValue
xCol = xCol + 1
End If
xCol = xCol + 1
Next xValue
Next xcount
Else
GoTo exitLoop
End If
Loop
exitLoop:
Close #1
End Sub
Function ReadLines() As Variant
On Error GoTo endfile
Dim codeStr, valStr As String
Line Input #1, LineOne
Line Input #1, LineTwo
Line Input #1, LineThree
Line Input #1, LineFour
Line Input #1, LineFive
Line Input #1, LineSix
ReadLines = Array(LineOne, LineTwo, LineThree, LineFour, LineFive, LineSix)
Exit Function
endfile:
ReadLines = Array("End_Of Line", "End_Of Line")
End Function
Bookmarks