98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Reading in text files
Reading in text files
Resolved · Medium Priority · Version 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 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
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Saving your Excel Spreadsheet as a CSV FileIn situations where you need to save your Excel spreadsheet as a CSV file, follow these simple steps. |