+ Reply to Thread
Results 1 to 5 of 5

Import multiple Fixed-Width .txt files into the same worksheet

  1. #1
    Registered User
    Join Date
    11-14-2012
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    3

    Import multiple Fixed-Width .txt files into the same worksheet

    Hello,

    I am an absolute novice with VBA and Macros. I have a bunch of .txt files that have data in columns with a fixed width. I would like to have a macro that can import all the data in the .txt files in a certain directory to a single worksheet. I have attached an example of one of the .txt files. Note that although this file has only one row, that will not be true of all the files. I appreciate any help!


    H_inertial_6_3_3.txt

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,844

    Re: Import multiple Fixed-Width .txt files into the same worksheet

    My choice for this sort of thing is to use the "import external data" command. When you call this utility, it will ask for a file, you point to the text file, which will then bring up the "text import" wizard where you can specify fixed width, specify where the column breaks should occur, and so on. Usually, once this is done for one file, I copy the tab, then have each tab import a different file. Then, if desired, you can add a summary worksheet that consolidates data from each tab into the desired format. to this point, no VBA/Macro is required, which might be useful for an absolute novice to VBA.

  3. #3
    Registered User
    Join Date
    11-14-2012
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Import multiple Fixed-Width .txt files into the same worksheet

    Thanks for the response, that's what I have been doing essentially, I just wanted a way to automate the process.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,844

    Re: Import multiple Fixed-Width .txt files into the same worksheet

    I just wanted a way to automate the process.
    One thing I've found -- sometimes I spend more time and energy trying to automate something tedious than I would have spent just doing the task the tedious way. Obviously, I can't decide for you if the effort to learn this is going to be greater than the effort needed to do it "the hard way."

    Perhaps the easiest way for an "absolute novice" to start learning to automate this kind of process is to start the macro recorder and run through a couple of iterations. This will give you a syntactically correct (though not very efficient) block of code that you can start from.

  5. #5
    Registered User
    Join Date
    11-14-2012
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Import multiple Fixed-Width .txt files into the same worksheet

    Yeah in this instance, I think I'm just being lazy and it's probably going to be easier to just do it the hard way. Thanks for the help/advice.

+ 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