loading Data in VBA from a text file

Posted by omegayen on Stack Overflow See other posts from Stack Overflow or by omegayen
Published on 2010-05-21T18:50:25Z Indexed on 2010/05/24 15:11 UTC
Read the original article Hit count: 189

Filed under:
|
|
|
|

I am not very familiar with VBA but need to use it for a new software program I am using (not Microsoft related)

I have a text file that has columns of data I would like to read into VBA.

Specifically the text file has 4 entries per row. Thus I would like to load in the column vectors (N by 1).

The text file is separated by a space between each entry.

So for example I want to load in column one and save it as array A, then column two and save as array B, then column three and save as array C, and then column four and save as array D.

This code snippet found below from http://www.tek-tips.com/faqs.cfm?fid=482 is something I found that can load in text to an array, but I need to adapt it to be able to save the columns as different arrays as specified above...

Open "MyFile.txt" For Input As #1
ReDim Txt$(0)
Do While Not EOF(1)
ReDim Preserve Txt$(UBound(Txt$) + 1)
Input #1, Txt$(UBound(Txt$))
Loop
Close #1

© Stack Overflow or respective owner

Related posts about file

Related posts about vba