+ Reply to Thread
Results 1 to 7 of 7

Apply macro to all workbooks in folder

  1. #1
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Apply macro to all workbooks in folder

    Hi everyone,

    I have the following codes:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    I run them both via:

    Please Login or Register  to view this content.
    However, i was wondering if there was a way I could apply this to all of the workbooks in a particular folder? Simply to save having to do this to a large number of spreadsheets.

    There are 61 spreadsheets in a folder called "GR12 Schedules" and each file is called "GR12 Schedule" and then a number i.e Schedule 1, Schedule 2 etc up to 61

    Many thanks,

    Chris

  2. #2
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365 Version 2501 64-bit
    Posts
    1,468

    Re: Apply macro to all workbooks in folder

    I adapted this to open each file in a Folder, but if any of the workbooks are password protected, don't forget to use a "wildcard" when defining the file type to open.

    https://www.thespreadsheetguru.com/t...a-given-folder

    Hope it helps

    Ochimus
    Last edited by Ochimus; 12-11-2020 at 06:53 AM.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Apply macro to all workbooks in folder

    Change the folder path to suit.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Apply macro to all workbooks in folder

    Hi AlphaFrog,

    Many thanks for your response, much appreciated

    I have amended your code to fit with the correct folder locations etc and I am getting "0 files coloured" messaged at the end.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Apply macro to all workbooks in folder

    Can you show your amended code?

  6. #6
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Apply macro to all workbooks in folder

    Please Login or Register  to view this content.

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Apply macro to all workbooks in folder

    Missing the trailing \

    sPath = "J:\XXXXXX\XXXXXXXX\CPA\Part 2\Schedules\"

    Isn't your folder called "GR12 Schedules" ?

+ 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. How to make a recorded macro apply to various workbooks
    By NeedhelpwithExcel2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-29-2017, 04:59 PM
  2. apply macros to a folder which has all the workbooks
    By gauti14 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2017, 12:32 PM
  3. Apply a macro across a hundred workbooks, and then copying the results into a master Excel
    By icomefromchaos in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-24-2014, 12:21 PM
  4. Apply Macro to all files in a specific folder.
    By AntiPivotTable in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2013, 12:48 PM
  5. Apply Macro to multiple Workbooks at Once
    By Prevostb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-11-2012, 05:25 PM
  6. Apply Macro to a folder of files
    By Costasg in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2011, 07:56 AM
  7. Apply the same macro code to all excel files in a folder
    By Alano in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-09-2007, 09:26 AM

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