Fill Array from a CSV File

  • Thread starter Thread starter mudraker
  • Start date Start date
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
 
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
 
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.
 
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.
 
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
 
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
 
Back
Top