Hi
Am having trouble using VBA to load data into Excel from a CSV file, where the data in the file is mal-formed, thus:
A,B,C,D,E,F 'line 1
A,B 'start of line 2
C '....
D,E,F 'end of line 2
A,B,C,D,E,F 'line 3
So far, I have written a loop for 6 items on a line that reads A..F okay (i.e. line1, line 3) but the loop does not detect when the data is split over several lines.
The code below:
Dim readStr As String
For item = 1 to 6 step 1
Input #1, readStr '1 is open file
Next item
gets to the end of the line (i.e. A,B) and then gives me 4 nulls or empty strings (i.e. A,B,"","","","").
Have tried to test
if readStr = "" or readStr = chr(13) or readStr = chr(10) then
end if
to detect an end-of-line but none of these tests succeed. It's frustrating because I can make an equivalent test succeed using C and Ada but not, as yet, in VBA.
Any help would be gratefully received
Best wishes
Colin the Browncoat!