Excel VBA - Working with arrays
Posted on 2003-02-28
I have used the code below to open a file, read the first line of a file into an array called headings(1)
The headings wil be in the format first name, last name, stud num, test1, test 2, test3, (Right up to test n),testn. Each heading is separated by a comma in the array.
How would I go about extracting each heading into a separate variable or array, bearing in mind that there could be five headings or 150? I know that I need to look for each comma and when it finds the comma store each heading separately.
Dim Headings(1) As String
Open "A:\Implementation\inputfile.csv" For Input As #1
Line Input #1, Headings(1)
MsgBox "First Line " & "in input file reads:" & Chr(13) & Headings(1)
The reason I need to do this is that the user needs to choose which headings to include in the analysis, so i need to extract each heading name and present it to the user to choose yes or no. Once I separate each heading name, would it be possible to pass this to a user form which could present it as a list of choices ?
Many thanks in advance