Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Reading .csv file into array

Hi,

I have a "comma separated values" file and I need to read it and load it
into an array using VBA. I cannot use any excel specific functions. How
do I do that? Actually, the file is generated from excel; I need to read
the file using VBA from a graphic program like CorelDraw or
AdobeIllustrator.

Thanks.

---------
MouseTrap
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Reading .csv file into array

Hi Mousetrap,

I have a "comma separated values" file and I need to read it and load it
into an array using VBA.


This code reads a file line-by-line. You can then separate out the
individual entries using the split function.

Sub test()
Dim sFile As String
Dim sArray() As String
Dim lCount As Long
sFile = "c:\data\book1.csv"
ReDim sArray(1)
Open sFile For Input As #1
Do
lCount = lCount + 1
ReDim Preserve sArray(lCount)
Line Input #1, sArray(lCount)
'place code here to split the read line into individual elements
Loop Until EOF(1)
Close #1
End Sub


Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reading from another file and pasting to current file, "combobox" Darius New Users to Excel 1 September 26th 05 07:13 AM
[excel 97 vba ] Reading ranges into an array steve Excel Programming 1 October 30th 03 02:10 PM
reading an arbitrary selection into a 1D array Jamie Martin[_2_] Excel Programming 5 September 30th 03 05:25 PM
Reading formatted cell values into an array Tom Ogilvy Excel Programming 0 September 19th 03 06:32 PM
Reading a cell into an array Tick-Tock Excel Programming 2 September 11th 03 07:33 PM


All times are GMT +1. The time now is 10:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"