read from .txt and extract data

Martynrbell

New Member
Joined
Apr 11, 2016
Messages
35
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
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,513
Office Version
365
Platform
Windows
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).
 

Martynrbell

New Member
Joined
Apr 11, 2016
Messages
35
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?
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,513
Office Version
365
Platform
Windows
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:

Forum statistics

Threads
1,082,610
Messages
5,366,601
Members
400,906
Latest member
incanus

Some videos you may like

This Week's Hot Topics

Top