+ Reply to Thread
Results 1 to 4 of 4

Copy text file after "phrase" in the text

  1. #1
    Registered User
    Join Date
    04-27-2011
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    10

    Copy text file after "phrase" in the text

    G'day
    I have a text file that I need to import into Excel. The file is generally about 100,000 lines but I only need the data after the phrase "Adjusted Coordinates". The location of the phrase changes within the text file as more data is added from the program that created it. It is unfortunately not a unique phrase as it is repeated a second time 3 lines later.

    I have had a crack at getting this to work but I currently have to manually delete all of the data above "Adjusted Coordinates" and then import it (see below).

    I would prefer if the required data can just be extracted from the text file without altering the original file.

    Attached is an example of the text file. I have taken a lot of the data out of it to make it a smaller file but I think the same principle should apply.

    Thanks in advance

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by fredo; 04-29-2011 at 12:52 AM. Reason: Added Code Tags

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Copy text file after "phrase" in the text

    You could use this macro that creates 'temp.txt' file in the same path of your selected file and then delete it after import:

    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Copy text file after "phrase" in the text

    Hi fredo,
    or maybe something like
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  4. #4
    Registered User
    Join Date
    04-27-2011
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Copy text file after "phrase" in the text

    Thankyou both for you help.

    I went with the one Antoka05 suggested as I understang what is happening in each step (still very new to VBA).

    I have tried it with the large file (100,000 lines) and it works great.

    Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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