reading text files
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

Reading in text files

resolvedResolved · Medium Priority · Version 2007

replyReply Mon 19 Dec 2011, 08:02Delegate Vlad said...

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

For upcoming training course dates see: Pricing & availability

replyReply Wed 21 Dec 2011, 09:51Trainer Anthony said...

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

replyReply Mon 9 Jan 2012, 08:01Delegate Vlad said...

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.

 

Please browse our web site to find out more about
microsoft+excel+training+london and other Microsoft training courses.

Excel tip:

Hiding and unhiding rows using the keyboard

CTRL + 9 hides your columns and CTRL + SHIFT + ( unhides them although you would need to highlight the row letters either side as per normal

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard