+ Reply to Thread
Results 1 to 15 of 15

Loop a macro through the multiple files

  1. #1
    Registered User
    Join Date
    11-08-2014
    Location
    Malaysia
    MS-Off Ver
    2010
    Posts
    84

    Question Loop a macro through the multiple files

    Hello members,
    I have already recorded a macro and created an add-in for my CSV files.
    I have more than 1000 csv files and I have to open the files one by one and run the add-in for each and then save & close.
    How can I run the add-in for all files in a folder without opening each separately?

    Thank you

    ** I have changed the topic based on the comments to find the best solution.
    Last edited by Moriexcel; 11-24-2014 at 11:13 AM. Reason: added more explanation

  2. #2
    Forum Contributor
    Join Date
    09-05-2012
    Location
    Dubai
    MS-Off Ver
    Office 365
    Posts
    409

    Re: How to run an add-in for multiple files?

    Try to Save file which has macro as type Excel add in system default location...
    then open any of your file and go to Developer options (Add Ins) It will show you available add ins stored... Select your saved Add In...

    It should work in all files then......


    Regards

  3. #3
    Valued Forum Contributor Kamboj's Avatar
    Join Date
    09-25-2014
    Location
    India
    MS-Off Ver
    2003 - 2010
    Posts
    430

    Re: How to run an add-in for multiple files?

    goto excel option by click on office button, then click on Add-Ins and select Go button and then browse your addin, this will add your add-in in excel.

  4. #4
    Registered User
    Join Date
    11-08-2014
    Location
    Malaysia
    MS-Off Ver
    2010
    Posts
    84

    Re: How to run an add-in for multiple files?

    I have 1000+ files and I would like to run my created add-in just one time for the all files in the folder without opening the files separately.

  5. #5
    Forum Contributor
    Join Date
    09-05-2012
    Location
    Dubai
    MS-Off Ver
    Office 365
    Posts
    409

    Re: How to run an add-in for multiple files?

    Have you tried the same above ? ( My post)

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: How to run an add-in for multiple files?

    I don't see any point in creating an add-in for that situation. Just put your code in a normal module and add a loop through all files in a folder.

  7. #7
    Registered User
    Join Date
    11-08-2014
    Location
    Malaysia
    MS-Off Ver
    2010
    Posts
    84

    Re: How to run an add-in for multiple files?

    I can run my add-in with no problem on all my files. The problem is I don't want to do it one by one.

  8. #8
    Registered User
    Join Date
    11-08-2014
    Location
    Malaysia
    MS-Off Ver
    2010
    Posts
    84

    Re: How to run an add-in for multiple files?

    Quote Originally Posted by StephenR View Post
    I don't see any point in creating an add-in for that situation. Just put your code in a normal module and add a loop through all files in a folder.
    Ok. Good point ! So how should I do that? Could you please help me?
    I'm trying to search and find it.
    Last edited by Moriexcel; 11-20-2014 at 09:38 AM.

  9. #9
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: How to run an add-in for multiple files?

    There are many examples of that if you Google - if you get stuck on something specific post back, and include your code.

  10. #10
    Registered User
    Join Date
    11-08-2014
    Location
    Malaysia
    MS-Off Ver
    2010
    Posts
    84

    Re: Loop a macro through the multiple files

    Could you please help me to solve this issue?
    This loop for my macro shows me 'run time error 1004' in Line 16.

    Please Login or Register  to view this content.
    Last edited by Moriexcel; 11-22-2014 at 01:29 PM.

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Loop a macro through the multiple files

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  12. #12
    Registered User
    Join Date
    11-08-2014
    Location
    Malaysia
    MS-Off Ver
    2010
    Posts
    84

    Re: Loop a macro through the multiple files

    Quote Originally Posted by shg View Post
    Please Login or Register  to view this content.
    Yes. It works. Thank you.
    There is another problem.
    My original recorded macro can do the work completely for one file, but I can not put Step 5 in the loop in polished version of macro (next code).

    Please Login or Register  to view this content.
    This one is the polished one. The step 5 is not included in this code.
    Please Login or Register  to view this content.
    Last edited by Moriexcel; 11-23-2014 at 06:42 AM.

  13. #13
    Registered User
    Join Date
    11-08-2014
    Location
    Malaysia
    MS-Off Ver
    2010
    Posts
    84

    Re: Loop a macro through the multiple files

    ****************
    Last edited by Moriexcel; 11-24-2014 at 11:19 AM.

  14. #14
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Loop a macro through the multiple files

    I don't really understand that code, but it might be enough to add a few dots
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    11-08-2014
    Location
    Malaysia
    MS-Off Ver
    2010
    Posts
    84

    Re: Loop a macro through the multiple files

    Yessssssss. Many thanks Stephen & Shg.
    I already clicked on '*'.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to open multiple files, remove header and save multiple files in a new format
    By twocircles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2014, 05:24 PM
  2. Produce multiple PDF files from multiple Excel Files
    By yukipilas in forum Excel General
    Replies: 2
    Last Post: 09-02-2013, 06:52 AM
  3. split text files stored in some location to multiple files based on a condition
    By GIRISH_KH in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-01-2013, 11:32 AM
  4. [SOLVED] Macro to Import Multiple TXT Files into workbook - User to select files/directory
    By saber007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-15-2013, 08:43 PM
  5. Replies: 0
    Last Post: 11-27-2012, 01:43 PM

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