+ Reply to Thread
Results 1 to 2 of 2

Run macro in all files from a folder

  1. #1
    Registered User
    Join Date
    04-02-2012
    Location
    Brasil
    MS-Off Ver
    Excel 2010
    Posts
    20

    Run macro in all files from a folder

    Earlier I posted this thread:
    http://www.excelforum.com/excel-prog...worksheet.html

    mrice nicely solved my problem but now I have another one.

    I need to run the macro I just created on 500 + files, and those files are not excel workbooks (*.xls). They are pure text files that I open with excel and then the excel do the job of converting tabulations in columns.

    The macro Im using is this

    Please Login or Register  to view this content.
    I have no idea where to start, most of my "googling" takes me to threads teaching how to activate a pre-existent macro on a bunch of files.

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Run macro in all files from a folder

    Open one of the text files with the macro recorder running to generate the basic VBA code for opening a text file (Text Import Wizard). Edit the code to incorporate a Dir loop (see VB Help or Google) to loop through the 500 files. For each file, open it, call your existing code (which you will probably have to modify slightly), then close and save it (use the macro recorder again to generate the VBA for saving a file).
    Post responsibly. Search for excelforum.com

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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