+ Reply to Thread
Results 1 to 4 of 4

Importing multiple .txt files

  1. #1
    Registered User
    Join Date
    06-30-2010
    Location
    La Jolla, Ca
    MS-Off Ver
    Excel 2007
    Posts
    1

    Importing multiple .txt files

    Good day,

    I came across a couple of threads that are somewhat related to my problem, but am really new to creating a macro that I feel more comfortable getting details specific to my issue.
    So I have data in the form of multiple .txt files that I usually import manually. I was able to record a macro of what it is that I am doing, and was able to loop it to repeat, but I would like to have the macro access all the .txt files in the folder and manipulate them in the same way, with a column separating each file (in one spreadsheet). How do I change the macro so that it goes thru each .txt file without me having to specify the exact file name?

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    08-29-2007
    Posts
    47

    Re: Importing multiple .txt files

    Not sure if there's a way to do an entire directory, but it might be possible if you created a list of all the files. Here are some ways to export the contents of a folder into a list.

    Then make your filename a variable that works its way down the list as you go.

    I would suggest testing this in a separate folder with maybe 3 or 4 txt files. No sense sitting there for an hour only to find out it didn't work.

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Importing multiple .txt files

    Hi dominiquetrix;

    Change your macro like this
    Please Login or Register  to view this content.
    Then run this macro to call your macro with all the file names in your folder
    Please Login or Register  to view this content.
    I haven't tested this so there could be bugs, but it should get you started.
    I would start the macro with F8 and step through the code one line at a time until you're satisfied that it's working right, then click F5 to do the rest automatically.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  4. #4
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Importing multiple .txt files

    Hi dominiquetrix,

    What is your delimiter in the text files? Tab, space, both or sometimes either. The reason I ask is that in your original macro that you recorded you had both boxes for Tab and space delimiter checked. If you only need one, then your code can reflect this.

    abousetta

+ 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