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