Hi,
I have a text file that was produced by a Unix program in CSV format. I am trying to parse it using Excel and thought I could automate the task using Excel VBA.
However, the script I wrote VBA is not detecting the end of file and the loop goes infinite. It does not exit the Do Loop when all the data has been read in. Any help would be greatly appreciated.
Sub OpenTextFile()
Dim FilePath As String
Dim columns As Long
FilePath = "C
Temp\Data.csv"
Open FilePath For Input As #1
row_number = 0
columns = 0
Do Until EOF(1)
Line Input #1, LineFromFile
LineItems = Split(LineFromFile, ",")
If row_number > 0 Then
Do While columns < 16
ActiveCell.Offset(row_number, columns).Value = LineItems(columns)
columns = columns + 1
Loop
columns = 0
End If
row_number = row_number + 1
Loop
Close #1
End Sub
I have a text file that was produced by a Unix program in CSV format. I am trying to parse it using Excel and thought I could automate the task using Excel VBA.
However, the script I wrote VBA is not detecting the end of file and the loop goes infinite. It does not exit the Do Loop when all the data has been read in. Any help would be greatly appreciated.
Sub OpenTextFile()
Dim FilePath As String
Dim columns As Long
FilePath = "C
Temp\Data.csv"Open FilePath For Input As #1
row_number = 0
columns = 0
Do Until EOF(1)
Line Input #1, LineFromFile
LineItems = Split(LineFromFile, ",")
If row_number > 0 Then
Do While columns < 16
ActiveCell.Offset(row_number, columns).Value = LineItems(columns)
columns = columns + 1
Loop
columns = 0
End If
row_number = row_number + 1
Loop
Close #1
End Sub