+ Reply to Thread
Results 1 to 5 of 5

Thread: Extracting Data from a .txt file

  1. #1
    Registered User
    Join Date
    08-27-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Extracting Data from a .txt file

    Hi

    I am trying to copy several rows of data from a text file. I have had a look through previous threads and cant find anything that explains how to copy more than one row over so I am hoping someone else can help me.

    I have a large text file - I have attached a small extract. So far I have managed to search the file and import the digit 1 out of the first row "Matrix 1" (trust me thats progress). The next step I want to do is literally copy the proceeding 109 rows. Is this possible - I know I could do it manually but I have 350 files with a minimum of 16 of these matrices in each.

    Hope you can help

    Thanks

    Rachael
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    11-09-2008
    Location
    germany
    Posts
    74

    Re: Extracting Data from a .txt file

    Quote Originally Posted by baby_rach View Post
    So far I have managed to search the file and import the digit 1 out of the first row "Matrix 1" (trust me thats progress).
    How are you doing this?

    Something like this
    Open "c:\sim1.txt" For Input As #1
    Do While Not EOF(1)
    Input #1, Data
    Where Data then is a text string?

    If yes, the only way I know how to then get the information you need is to use VBA string functions like "LEFT" "MID" "INST" etc.

  3. #3
    Registered User
    Join Date
    08-27-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extracting Data from a .txt file

    Yes darbid

    At the minute i am searching for the string. I was worried that would be the case as the only way I could think to do it was to call each of the 109 lines in idividually and using this function which seems an awkward way round.

  4. #4
    Registered User
    Join Date
    11-09-2008
    Location
    germany
    Posts
    74

    Re: Extracting Data from a .txt file

    Just because I am saying it is the only way I KNOW how to do it does not mean it is the only way. I am happy for someone to tell me otherwise. At the moment it is the way I have handled such things.

  5. #5
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,757

    Re: Extracting Data from a .txt file

    The data is separated by multiple spaces. How would you expect that to import? Post an example workbook for the example text?
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

+ 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.2.0