Hi guys,
I need a fast method of loading a multicolumn listbox using lines in a text file.
Here is the code i am using
FF = FreeFile
If Dir(ThisWorkbook.Path & "\abc.txt") <> "" Then
Open ThisWorkbook.Path & "\abc.txt" For Input As #FF
Do While (EOF(FF) = False)
Line Input #FF, str1
If Mid(str1, 9, 1) = "D" Then
With lstExisting
.AddItem Mid(str1, 1, 3) ' add a new row
.List(i - 1, 0) = Mid(str1, 1, 3)
.List(i - 1, 1) = Mid(str1, 4, 4)
.List(i - 1, 2) = Mid(str1, 9, 4)
.List(i - 1, 3) = Mid(str1, 10, 3)
.List(i - 1, 4) = Mid(str1, 53, 5)
.List(i - 1, 5) = Mid(str1, 13, 40)
End With
i = i + 1
End If
Loop
Close #FF
Is there a better way?
Start Free Trial