Results 1 to 4 of 4

Thread: read from .txt and extract data
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Apr 2016
    Posts
    35
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default read from .txt and extract data

    Hi All,

    I need to read a txt file and dump the data into a spreadsheet.

    each txt file with contain two different data sets always starting with DXE and ending with DXS

    Id like to extract the first set in to column A
    and second set into column B

    the data needs to be inserted row by row, rather then in just A1.

    This would be great if anyone could help me out with this

    Thanks

  2. #2
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    51,032
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: read from .txt and extract data

    I have done things like this before, and what I have always done is import the whole text file, as-is, into multiple rows in Excel (one for each record).
    Whether or not you will import into multiple columns right away depends on the structure of the data, and whether you have delimiters that can be determined (and it is needed).

    Then, once all the data is in your Excel file, you can loop through the data to manipulate it, any way you need (to delete rows, move data, etc).
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  3. #3
    New Member
    Join Date
    Apr 2016
    Posts
    35
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: read from .txt and extract data

    Ah so you say to dump it all in to column A
    Then loop through and move the data sets from there.

    Loop A and find DXS,
    Move each row to B until I get to DXE.

    Then Loop A again and find DXS,
    Move each row to C until I get to DXE.

    Something like that?

  4. #4
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    51,032
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: read from .txt and extract data

    Yes, something like that.
    If you want to avoid loops, you can use "Find" down the column to find where each of those things occur, get a first row and last row, and move the whole block at once.
    It will probably be a bit more efficient, as loops tend to be a bit slow (not always noticeable, but may be if you are doing thousands of rows).
    Last edited by Joe4; Sep 12th, 2019 at 05:25 PM.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •