+ Reply to Thread
Results 1 to 8 of 8

How to open multiple text files?

  1. #1
    Registered User
    Join Date
    04-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    85

    How to open multiple text files?

    I'd like to open all ".txt" files in a folder one by one to extract data into a worksheet - would someone have some code which does this or something similar please? Thanks in advance!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to open multiple text files?

    Here's a macro I've got that imports XLS files as separate sheets. If you use the macro recorder to record you opening ONE of your text files, you could probably mix that code with this to get a macro that does what you need.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    04-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: How to open multiple text files?

    Thanks for that - I've got something similar but remember seeing some code to loop through all the files in a folder until it reaches the end, which is what
    I'm stuck on at the moment. The help file is no help on this one as far as I can see

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: How to open multiple text files?

    Hello jp001,

    Do you mean to search all subfolders within the folder, and then all subfolders of the subfolders till there are no more?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    04-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: How to open multiple text files?

    Quote Originally Posted by Leith Ross View Post
    Hello jp001,

    Do you mean to search all subfolders within the folder, and then all subfolders of the subfolders till there are no more?
    No, just all the .txt files in the one folder thanks.

  6. #6
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    Re: How to open multiple text files?

    Hi
    The macro in this link
    http://www.excelforum.com/excel-prog...ets-macro.html
    opens each text file and imports to excel. Give it a try.
    Ravi

  7. #7
    Registered User
    Join Date
    04-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: How to open multiple text files?

    Thanks Ravi, but this is what I was looking for, simple and elegant:

    Please Login or Register  to view this content.
    Last edited by jp001; 08-08-2009 at 01:50 AM. Reason: addendum

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to open multiple text files?

    No one can be offended with a simple:

    "This is what I was looking for. Thanks for your help anyway."

    Your version...very easy to be put off by.

    ============
    Anyway. if that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1