read from .txt and extract data

Martynrbell

New Member
Joined
Apr 11, 2016
Messages
38
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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).
 
Upvote 0
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?
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top