Fill Array from a CSV File

M

mudraker

I need need help with code to open a csv file and then fill a
dimensional array with data contained in a csv file.

This is an example of a entry from the file.

Region,12345678,0001,Ex Code,525,Cust Name,Unit no,Street No,Street,S
Type,Suburb,Ex Code & Address,,,01-NOV-03,Raw Dat
String,,,,,,,,123456780001,17/10/03,10/10/03


There are approx 12,000 lines (rows) in the file which will increas
daily


thanks in advanc
 
J

Jase

Personally I would create a new sheet and import it to
there. Then fill the array off the new sheet you have
created. I am not sure of the code to do this but you
should be able to record it or someone else will know.

Jase
 
T

Tom Ogilvy

Dim varr as Variant
workbooks.Open "C:\my files\myfile.csc
varr = Activeworkbook.Worksheets(1).UsedRange.Value
Activeworkbook.close Savechanges:=False
now varr is a two dimensional array containing your values.

--
Regards,
Tom Ogilvy

Jase said:
Personally I would create a new sheet and import it to
there. Then fill the array off the new sheet you have
created. I am not sure of the code to do this but you
should be able to record it or someone else will know.

Jase
-----Original Message-----

I need need help with code to open a csv file and then fill a 2
dimensional array with data contained in a csv file.

This is an example of a entry from the file.

Region,12345678,0001,Ex Code,525,Cust Name,Unit no,Street No,Street,St
Type,Suburb,Ex Code & Address,,,01-NOV-03,Raw Data
String,,,,,,,,123456780001,17/10/03,10/10/03


There are approx 12,000 lines (rows) in the file which will increase
daily


thanks in advance


------------------------------------------------
[/url]
~~View and post usenet messages directly from http://www.ExcelForum.com/

.
 
S

shockley

Cool!!


Tom Ogilvy said:
Dim varr as Variant
workbooks.Open "C:\my files\myfile.csc
varr = Activeworkbook.Worksheets(1).UsedRange.Value
Activeworkbook.close Savechanges:=False
now varr is a two dimensional array containing your values.

--
Regards,
Tom Ogilvy

Jase said:
Personally I would create a new sheet and import it to
there. Then fill the array off the new sheet you have
created. I am not sure of the code to do this but you
should be able to record it or someone else will know.

Jase
-----Original Message-----

I need need help with code to open a csv file and then fill a 2
dimensional array with data contained in a csv file.

This is an example of a entry from the file.

Region,12345678,0001,Ex Code,525,Cust Name,Unit no,Street No,Street,St
Type,Suburb,Ex Code & Address,,,01-NOV-03,Raw Data
String,,,,,,,,123456780001,17/10/03,10/10/03


There are approx 12,000 lines (rows) in the file which will increase
daily


thanks in advance


------------------------------------------------
[/url]
~~View and post usenet messages directly from http://www.ExcelForum.com/

.
 
M

mudraker

Tom

This looks exactly like what I am after

Is there a simular simple way to fill a sheet with data held in a
Array


Thank
 
T

Tom Ogilvy

Assuming myarray is a 2-D array:

rw = Ubound(myarray,1)-lbound(myarray,1)+1
col = Ubound(myarary,2)-lbound(myarray,2)+1
Range("A1").Resize(rw,col).Value = myArray
 

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