Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Reading a CSV file into an Excel w/b

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Duncs - 27 Mar 2008 16:20 GMT
I'm guessing, from the posts I've seen, that the following code will
open and read the contents of a CSV file:

Sub read_file()
Dim strTemp As String
Dim arline As Variant

Open "c:\temp\myfile.csv" For Input As #1
Do While Not EOF(1)
   Line Input #1, strTemp
   arline = Split(strTemp, ",", -1, vbTextCompare)
Loop
Close #1
End Sub

What I would like to know is, how do I get the data that is read from
the CSV, into my Excel w/b?

I have a number of CSV files that I am sent monthly, which need to be
placed into a master w/b.  Some data manipulation needs to be
performed on the read data, e.g. dates appear in the format
'yyyymmddhhmmss' and need to be converted to 'dd/mm/yyyy hh:mm:ss'.
So, I guess my question is two-fold:

1. How do I get the data read in, and into the spreadsheet?
2. When do I perform the data manipulation and then get it into the
appropriate cells in the spreadsheet?

Many thanks for your help

Duncs
Ray C - 28 Mar 2008 16:09 GMT
Hi Duncs

I'm actually working on a similar project. From what I know, there is no
need for special importing in order to open a csv file into Excel. I simply
double-click the csv file in Wondows explorer and Excel opens it like any
.xls file. Then I manipulate the data like usual, with Excel functions. I'm
sure there are limitations but you should be able to do your date changes.

> I'm guessing, from the posts I've seen, that the following code will
> open and read the contents of a CSV file:
[quoted text clipped - 27 lines]
>
> Duncs
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.