ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Import a CSV into an array? (https://www.excelbanter.com/excel-programming/418889-import-csv-into-array.html)

Dave

Import a CSV into an array?
 
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

signon77

Import a CSV into an array?
 
On Oct 22, 3:17*pm, Dave wrote:
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

joel

Import a CSV into an array?
 
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.

"Dave" wrote:

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


Dave

Import a CSV into an array?
 
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...

"signon77" wrote:

On Oct 22, 3:17 pm, Dave wrote:
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


joel

Import a CSV into an array?
 
If your datra is that large, you should import the data into multiple columns
or worksheets.

"Dave" wrote:

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...

"signon77" wrote:

On Oct 22, 3:17 pm, Dave wrote:
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



All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com