+ Reply to Thread
Results 1 to 6 of 6

Excel reading entire file, not one line at a time

  1. #1
    Registered User
    Join Date
    12-08-2008
    Location
    Sacramento, CA US
    MS-Off Ver
    2007
    Posts
    17

    Excel reading entire file, not one line at a time

    Hello. Me again :-)
    I want to read in a space delimited file and to put each line in one cell starting with cell B2 (I will take care of splitting it into columns later). However, rather than reading one line at a time, it reads in the entire txt file at the first pass.

    --------------------------------------------------------------
    Unit Raw Reviewed UnReviewed.
    --------------------------------------------------------------
    au_io_wrapper 6 0 6
    (bunch of lines deleted for readibility)
    cpt_flat 51 0 51
    --------------------------------------------------------------
    Total 5905 0 5905
    --------------------------------------------------------------

    Please Login or Register  to view this content.
    The code executes once and puts the entire file (200+ lines) in cell B2.

    Any help is much appreciated.

    Angel
    Last edited by verdugan; 12-24-2008 at 01:38 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Angel

    You are not incrementing i as you pass through. Put in the line
    Please Login or Register  to view this content.
    before the loop statement.

    rylo

  3. #3
    Registered User
    Join Date
    12-08-2008
    Location
    Sacramento, CA US
    MS-Off Ver
    2007
    Posts
    17
    Rylo,

    Good catch. I have increased the value of i. However, that has not solved the problem.

    The very first time that the statement to read the line is executed (Line Input ...), strLine contains the entire file, not just one line. And the cell contains the entire file.

    So the second time the loop doesn't execute because it's at EOF.

    I've attached the data file I'm reading in case it helps.

    Thanks again.

    Angel
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    there seems to be a lf but no cr at the end of each row. Fiddled a bit and came up with this.

    Please Login or Register  to view this content.
    You will have to edit for the file location, and you may want to not clear out column A as well as B. I just did this so you can see what the full string looks like, and the broken output goes into column B.

    Not sure how you are going to split it from here as there is no consistency between the ID and the first number...


    rylo
    Last edited by rylo; 12-24-2008 at 02:39 AM.

  5. #5
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    If the file is not too big, one can read the data like this:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-08-2008
    Location
    Sacramento, CA US
    MS-Off Ver
    2007
    Posts
    17
    Thank you for the answers.

    I wasn't familiar with the Split function, but that's exactly what I needed.

    I am impressed with the knowledge and helpfulness of this forum.

    Happy Holidays,

    Angel

+ 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