|
-
Jul 17th, 2009, 11:28 AM
#1
Thread Starter
New Member
Reading data from CSV file
I'm trying to create a program using VBA within excel that will read specific data from a user specified CSV file. I would like the user to browse for and select the CSV file, and once selected, the program imports only the required variables from the file into the program to be used. ideally, this would be done without having to physically open the CSV file. it would just read it. is this something that an amateur VBA programmer could handle? does anyone have any advice or suggestions for me, to point me in the right direction. i am able to create a diolog box to open a CSV file, but that's about it so far.
thanks!
-
Jul 17th, 2009, 04:59 PM
#2
Re: Reading data from CSV file
you have to open the file to get the data, but it does not need to display to the user at all
what application are you working in?
vb Code:
open "somefile.csv" for input as 1 myarr = split(input(lof(1), #1), vbnewline) ' read whole file into array for processing close 1
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|