+ Reply to Thread
Results 1 to 2 of 2

Best way to import fixed-width delimited text files into an array?

  1. #1
    KR
    Guest

    Best way to import fixed-width delimited text files into an array?

    Should I use the Workbooks.OpenText Filename, or is there a faster way to
    bring in the file?

    Actually, I may not even need the file in a worksheet, I just need the data
    in an array so I can use it to manipulate an existing excel file...so would
    it be faster to do some alternate type of file read directly into a
    2-dimensional array?

    Thanks for any advise,
    Keith

    --
    The enclosed questions or comments are entirely mine and don't represent the
    thoughts, views, or policy of my employer. Any errors or omissions are my
    own.



  2. #2
    Tom Ogilvy
    Guest

    Re: Best way to import fixed-width delimited text files into an array?

    You can use low level fileio:

    http://www.applecore99.com/gen/gen029.asp


    http://support.microsoft.com/support...eio/fileio.asp
    File Access with Visual BasicĀ® for Applications


    Sub ReadStraightTextFile()
    Dim LineofText As String
    Dim rw as Long
    rw = 0
    Open "C:\FILEIO\TEXTFILE.TXT" For Input As #1
    Do While Not EOF(1)
    Line Input #1, LineofText
    rw = rw + 1
    ' now parse LineofText according to the column widths and
    ' put the values in an array.
    Loop
    'Close the file
    Close #1
    End Sub

    --
    Regards,
    Tom Ogilvy

    "KR" <[email protected]> wrote in message
    news:[email protected]...
    > Should I use the Workbooks.OpenText Filename, or is there a faster way to
    > bring in the file?
    >
    > Actually, I may not even need the file in a worksheet, I just need the

    data
    > in an array so I can use it to manipulate an existing excel file...so

    would
    > it be faster to do some alternate type of file read directly into a
    > 2-dimensional array?
    >
    > Thanks for any advise,
    > Keith
    >
    > --
    > The enclosed questions or comments are entirely mine and don't represent

    the
    > thoughts, views, or policy of my employer. Any errors or omissions are my
    > own.
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1