How to open a delimited text file in a single column

spiralrain

New Member
Joined
Mar 24, 2018
Messages
23
Hello, I wrote a macro a few years ago in Excel 2010 that opens a series of text files, imports the data, and manipulates it as needed. Our computers are being updated and we are getting Excel 2013. So I'm trying to update the code for my macro in preperation for this. The original line of code (that i'm now having trouble with) is:

Workbooks.OpenText ("C:\Users\Me\Desktop\Testdoc.txt"), DataType:=xlDelimited, Tab:=True

This line of code (in excel 2010) would open the text file in an excel document and all of the lines would be in a single column (which is what I want).

However, using excel 2013 and the same line of code, the text file is opened and often puts the lines in several columns (and once, in a single row with each line in a different column).

The lines of information within the text document have strings, numbers and dates. Each line is seperated by a tab.

I have been googling the problem, but have been unable to find an answer. Any help you can provide will be appreciated.
 
I'm about to head home for the day (so I won't be able to test that until I get back to work in the morning, as I can't take the text files home with me.)
Im not familiar with the Offset or Transpose code, but if it does what I think, then this may be exactly what I need. I'll let you know in the morning.
Thanks for everything so far.
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Thank you for your help. This did the trick. I don't know how I never learned about Transpose before now. As to why my code was behaving differently in XL2010, I have no idea. However, because of your help, I'll be able move on with re-coding my macro and can save that mystery for another time. Again, Thank you for your help.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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