Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

reading text files

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Reading in text files

Reading in text files

ResolvedVersion 2007

Vlad has attended:
Excel VBA Intro Intermediate course

Reading in text files

Hi Anthony and thanks for the course last week!

As we discussed when you were at Saipem, could you please send me a couple of lines of code I can use for reading in Text files with data and performing the "text to column" function on them (some are space delimited, others comma delimited).

Many thanks!

Vlad

RE: Reading in text files

Hi Vlad, thanks for your query. A couple of lines might be an underestimation. First of all, have a look at the code generated by the macro recorder when you record yourself importing text and using text to columns, it's not that complicated. However, for a more formal walkthrough have a look at this link:

http://www.cpearson.com/excel/ImpText.aspx

There are several different ways to throw text around in Excel and I think using the basic import tool is the way you should go, rather than manipulating the file system object. Whichever way you decide to go, it's an extremely useful thing to be able to automate and you'll find a use for it in many different contexts.

Hope this helps,

Anthony

RE: Reading in text files

Hi Anthony,

Thanks for your answer, I've finally had a chance to try out the code in the link you posted and it does what I wanted. I also tweaked it so that it ignores multiple consecutive separators rather than creating blank cells.

Regards,

Vlad

Wed 28 Dec 2011: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Highlighting only Text cells

To select onlt text value cells in a spreadsheet, click on Edit-Go to(F5)


In the Go To dialog box, click Special.
In the Go To Special dialog box, select Constants.
Click OK.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.08 secs.