Importing text from another file into Excel list boxes


Posted by Kurt on August 27, 2000 11:20 AM

Hello all,

How can I use the following code to import text from another file into a list box in Excel 97?Sub FilterCrops()

Open "c:\crops.id" For Input As #1
Open "c:\cropsout.txt" For Output As #2

FindCrops = "CE"

Do While Not EOF(1)

Line Input #1, data

If InStr(1, data, FindCrops) Then
Print #2, data
End If

Loop
Close

End Sub

Thanks in advance,

Kurt



Posted by Ivan Moala on August 28, 0100 2:47 AM

Kurt
Try this in your userform code;
OR
change as necc for the prticular control
you want to action this.

Private Sub UserForm_initialize()
Dim FindCrops As String
Dim Data

Open "c:\crops.id" For Input As #1

FindCrops = "CE"

Do While Not EOF(1)
Line Input #1, Data
If InStr(1, Data, FindCrops) Then
ListBox1.AddItem (Data)
End If
Loop

Close

End Sub

Ivan