+ Reply to Thread
Results 1 to 7 of 7

Thread: reading values in from a text file

  1. #1
    Registered User
    Join Date
    06-12-2011
    Location
    Liberal,Kansas
    MS-Off Ver
    Excel 2003
    Posts
    3

    reading values in from a text file

    Hi Guys,

    I have a text files that contains various information I need to feed into excel, I have tried importing data but the values in the text file are not organized well enough.

    I would like to be able to search for a string like "field" and then store the the values on the same line immediately after it into excel. cells.


    PD1 * * Client and Well Information 03-MAY-2011 16:27
    PDB mode LIS USA
    Company XXX
    Well XXXX XX
    Field WILDCAT
    Prvnc/co XXX
    Cntry/st XX XXX
    Location XX XX XX
    Unique well Id.
    API Number XX XX API Number
    Location 2 SW SW NW NE
    Lsd Sec Twp Rge XX XX
    Permit number Permit Number
    Permanent Datum G.L.
    Elevation XXX feet
    Log Measured from K.B. @ 7 FEET
    Elevation above PD feet
    Elevn. of log zero feet
    Drill measured from K.B.
    Elevations: KB XXX F feet
    DF XXX F feet
    GL XXX F feet

  2. #2
    Registered User
    Join Date
    05-27-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010
    Posts
    7

    Re: reading values in from a text file

    pls send me the file, let me try
    Last edited by DonkeyOte; 06-26-2011 at 04:27 AM. Reason: removed unnecessary quote

  3. #3
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: reading values in from a text file

    vasantjob

    Don't quote whole posts unless necessary.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  4. #4
    Registered User
    Join Date
    06-12-2011
    Location
    Liberal,Kansas
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: reading values in from a text file

    Thanks for the help, I've attached the file.
    Attached Files Attached Files

  5. #5
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: reading values in from a text file

    @vasantjob,

    For reference: sample files should be attached on threads directly and not sent via PM/Email. Private correspondence rather defeats the purpose of a public forum.
    Sample files should of course be stripped of confidential info.

    @thegoat001, I would suggest posting an Excel file that shows desired results given sample data.

  6. #6
    Registered User
    Join Date
    06-12-2011
    Location
    Liberal,Kansas
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: reading values in from a text file

    I'm hoping that I do not need to post a sample excel file...once I know how to extract one value from the text files I'm hoping I can get the rest. Once the values are extracted and placed in individual cells I will be able to process them further. Some examples would be well name, company name, location, etc.

  7. #7
    Registered User
    Join Date
    05-27-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010
    Posts
    7

    Re: reading values in from a text file

    Quote Originally Posted by thegoat001 View Post
    I'm hoping that I do not need to post a sample excel file...once I know how to extract one value from the text files I'm hoping I can get the rest. Once the values are extracted and placed in individual cells I will be able to process them further. Some examples would be well name, company name, location, etc.
    try this

    
    Sub ReadFile()
    Fl = "C:\Documents and Settings\Desktop\Sample text file.txt"
    Dim myFileName As String
    Dim myLine As String
    Dim FileNum As Long
    myFileName = Fl
    FileNum = 1
    Close FileNum
    Open myFileName For Input As FileNum
    Do While Not EOF(FileNum)
        Line Input #FileNum, myLine
        Debug.Print myLine
    Loop
    End Sub

+ 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