+ Reply to Thread
Results 1 to 4 of 4

Thread: Read select "text" from "Text File" using VBA code

  1. #1
    Registered User
    Join Date
    08-23-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    7

    Post Read select "text" from "Text File" using VBA code

    Hello All;

    I have text file which has the following sample data like below:

    facility","scanLocation":"PHILADELPHIA, PA","scanTime":"12:57 AM","GMTOffset":"-05:00","showReturnToShipper":false,"scanDate":"Jan 19, 2012"},{"scanStatus":"Arrived at FedEx location","scanLocation":"PHILADELPHIA, PA","scanTime":"8:51 PM","GMTOffset":"-05:00","showReturnToShipper":false,"scanDate":"Jan 18, 2012"},{"scanStatus":"Picked up","scanLocation":"PHILADELPHIA, PA","scanTime":"12:40 PM","GMTOffset":"-05:00","showReturnToShipper":false,"scanDate":"Jan 18, 2012"}],"rthActive":true,"getLinkText":"Get Link","shipDateISO"


    Now i need a Macro which open this text file and find out the "Picked up" and capture the Date time & Picked up.

    Example:
    1111 - 1/18/2012 12:40 PM - Picked Up

    Regards,
    NG
    Last edited by naven_sg; 01-23-2012 at 02:18 PM. Reason: color

  2. #2
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,352

    Re: Read select "text" from "Text File" using VBA code

    Is this all in one line in the text file, or are these all different lines in the text file?
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Valued Forum Contributor
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    412

    Re: Read select "text" from "Text File" using VBA code

    I think you want to tracking some parcels

    for establish where is "Picked up" in text I suggest to use built function InStr
    let say your text file is loaded into variable text
    text = "facility","scanLocation":"PHILADELPHIA, PA","scanTime...
    PickUpPos = InStr(1,text, "Picked up")
    scanTime = mid(text,InStr(PickUpPos,text,"scanTime")+11,8)
    msgbox "Scan Time is: " & scanTime
    It is only my point of view, just try to adapt it to your needs.
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to use the Scales icon to rate it - This way you will add me some reputation points ... thanks in advance.

  4. #4
    Valued Forum Contributor
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    412

    Re: Read select "text" from "Text File" using VBA code

    I think you want to tracking some parcels

    for establish where is "Picked up" in text I suggest to use built function InStr
    let say your text file is loaded into variable text
    text = "facility","scanLocation":"PHILADELPHIA, PA","scanTime...
    PickUpPos = InStr(1,text, "Picked up")
    scanTime = mid(text,InStr(PickUpPos,text,"scanTime")+11,8)
    msgbox "Scan Time is: " & scanTime
    It is only my point of view, just try to adapt it to your needs.
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to use the Scales icon to rate it - This way you will add me some reputation points ... thanks in advance.

+ 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