Hi,
I need to populate the columns of a multicolumn listbox on a userform in Excel. I have read data from a text file and have ended up with an array of the values I wish to write to the listbox. A simple example:-
array = "one","two","three","four"
I do not know in advance how many rows there are in the text file, although I do know how many fields(columns), so any solution would allow me to iterate around until the end of the text file is reached. After I've read the line of data, and split this into separate fields, I want to write each field into the coresponding column in the listbox. Sounds easy but I'm having problems. I have tried:-
MyFile = IMPORTFILE(fImport)
With frmmain
.lstRunway.ColumnCount = 4
End With
For intI = 0 To UBound(MyFile)
S = MyFile(intI)
rtnTXT = SSPLIT(S)
With frmmain
.lstRunway.Column(0, intI) = rtnTXT(0)
.lstRunway.Column(1, intI) = rtnTXT(1)
.lstRunway.Column(2, intI) = rtnTXT(2)
.lstRunway.Column(3, intI) = rtnTXT(3)
End With
Next intI
IMPORTFILE is a custom function which returns a variant (string array).
SSPLIT is a custom function that splits a line into separate fields (uses SPLIT function but handles tabs and multiple spaces as well)
rtnTXT is a variant
I keep getting the error:-
Could not set the Column property. Invalid property array index.
Any pointers greatly appretiated
Tim
I need to populate the columns of a multicolumn listbox on a userform in Excel. I have read data from a text file and have ended up with an array of the values I wish to write to the listbox. A simple example:-
array = "one","two","three","four"
I do not know in advance how many rows there are in the text file, although I do know how many fields(columns), so any solution would allow me to iterate around until the end of the text file is reached. After I've read the line of data, and split this into separate fields, I want to write each field into the coresponding column in the listbox. Sounds easy but I'm having problems. I have tried:-
MyFile = IMPORTFILE(fImport)
With frmmain
.lstRunway.ColumnCount = 4
End With
For intI = 0 To UBound(MyFile)
S = MyFile(intI)
rtnTXT = SSPLIT(S)
With frmmain
.lstRunway.Column(0, intI) = rtnTXT(0)
.lstRunway.Column(1, intI) = rtnTXT(1)
.lstRunway.Column(2, intI) = rtnTXT(2)
.lstRunway.Column(3, intI) = rtnTXT(3)
End With
Next intI
IMPORTFILE is a custom function which returns a variant (string array).
SSPLIT is a custom function that splits a line into separate fields (uses SPLIT function but handles tabs and multiple spaces as well)
rtnTXT is a variant
I keep getting the error:-
Could not set the Column property. Invalid property array index.
Any pointers greatly appretiated
Tim