I wanna' be just like my daddy...
I want to open a CSV file into an already open Sheet the same way Excel opens it as a new, complete Workbook.
It is a simple CSV file with records (lines) that have either text or numbers in the fields (with commas between, of course) and CR at the end. There are no quotes around the strings (they aren't Write strings).
Typical records:
2,Anthem,442.525000,,5.000000,Tone,114.8,,,,,,,
3,Bank One,146.820000,-,0.600000,Tone,159.8,,,,,,,
As you see, there can even be blank fields, thus blank cells.
I already can and do open tab delimited files, but I use Input # and normally get the individual fields into individual variables by manually (code) parsing the resulting whole record (line) strings.
However, I want to open the file at the users command (a button push) and have the values put into adjacent cells just the way it happens when you open a CSV file using Excel's Open. [Recording this operation shows that it simply opens another complete Workbook.]
Help says that Line Input # is for reading Print # lines.
and that
Input # is for reading Write # lines...
but that the fields are brought into individual variables.
I don't know if this can be done automatically, or if I must bite the bullet and use code to parse the values and put them in cells.
I didn't know where to start looking.
I spoze' I could do a regular Open a CSV Workbook, copy to the desired Sheet, then close the CSV Workbook, but it would seem since Excel does it, VBA should be able to make that happen as well.
Ya' know
something like "Application.OpenCSVFile = xlJustLikeExcel Filename = "whatever" Destination=Sheet4"
(;-)
--
73, Steve
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar