+ Reply to Thread
Results 1 to 5 of 5

find a certain line (repetitive line with no identifier) in txt file vba

  1. #1
    Registered User
    Join Date
    08-22-2015
    Location
    Qatar, Doha
    MS-Off Ver
    2010
    Posts
    9

    find a certain line (repetitive line with no identifier) in txt file vba

    Dear vba experts,
    I have a text file which I am attaching in this thread. It is a file which contains information for a certain Traffic Junction. The file contains several junctions. The header of the text file will have the following information:

    [/QUOTE]
    8/3/2015 Baseline Synchro 8 Report
    Page 0
    Lanes, Volumes, Timings
    1: 8/27/2015
    /newline
    /newline
    Information
    information
    /newline
    /newline
    8/3/2015 Baseline Synchro 8 Report
    Page 0
    Lanes, Volumes, Timings
    2: 8/27/2015
    /newline
    /newline
    Information
    information
    /newline
    /newline[/QUOTE]
    I need to extract the numbers 1,2, etc... which represents the junction number, and since there is no string identifier i.e. Intersection number before the "1,2", I don't know how to search for them using InStr command. I am attaching the text file for a full picture of the text file.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: find a certain line (repetitive line with no identifier) in txt file vba

    This tests if a colon is found in the left three characters of a line. Then extracts the text before the colon.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    08-22-2015
    Location
    Qatar, Doha
    MS-Off Ver
    2010
    Posts
    9

    Re: find a certain line (repetitive line with no identifier) in txt file vba

    That is a good idea, however if the numbers are 3 digits and 2 digits this wouldn't work. right?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: find a certain line (repetitive line with no identifier) in txt file vba

    Quote Originally Posted by freeky1 View Post
    That is a good idea, however if the numbers are 3 digits and 2 digits this wouldn't work. right?
    It should work if you check the left 4 characters assuming 3 is the max digits.

  5. #5
    Registered User
    Join Date
    08-22-2015
    Location
    Qatar, Doha
    MS-Off Ver
    2010
    Posts
    9

    Re: find a certain line (repetitive line with no identifier) in txt file vba

    Quote Originally Posted by AlphaFrog View Post
    It should work if you check the left 4 characters assuming 3 is the max digits.
    great thanks Alpha.
    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Save outlook attachments and rename/append files with identifier from subject line
    By XLnExcel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-18-2015, 12:49 PM
  2. [SOLVED] Reading line by line data from Text file
    By wyldencl in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-18-2015, 10:09 PM
  3. Find a phrase in file, copy another value on the same line to another file
    By exseller in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-18-2015, 06:32 AM
  4. [SOLVED] read pdf or doc file line by line and then parse the data into the proper cells and rows.
    By rtphilli in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-04-2014, 03:33 AM
  5. [SOLVED] Comparing two data sets that don't line up on a line to line basis
    By ghan7650 in forum Excel General
    Replies: 10
    Last Post: 05-22-2012, 05:38 PM
  6. analyzing text file line by line
    By HarryKlein in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-16-2011, 12:20 PM
  7. [SOLVED] Reading a text file line by line
    By Foss in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2005, 12:06 PM

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