Import a CSV into an array?

D

Dave

I'm trying to import a csv file into a 2D array in VBA, for example:

myFile(column_count,row_count), is this possible?

Thanks
 
S

signon77

I'm trying to import a csv file into a 2D array in VBA, for example:

myFile(column_count,row_count), is this possible?

Thanks

One way that comes to mind is to first import the csv file into a
worksheet then use the following code:

Assuming you've imported the sheet into Sheet1:

Sub Create2DArray()

Dim TwoDArray() As Variant

TwoDArray = Sheets(1).UsedRange.Value

End Sub
 
J

Joel

Dave: As I responded yesterday, you have to open the file and read one line
at a time. then use the split functions to seperate athe data into an array.
 
D

Dave

A good idea, I'm actually trying to avoid importing the data into a tab,
however, because I'm still in Excel 2003 and I'd run into the 65k column and
256 row limits that way...
 
J

Joel

If your datra is that large, you should import the data into multiple columns
or worksheets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top