+ Reply to Thread
Results 1 to 4 of 4

Excel Macro to Format all Worksheets in Multiple WB in a folder based on Given Criteria

  1. #1
    Registered User
    Join Date
    03-01-2017
    Location
    Manila, Philippines
    MS-Off Ver
    MS Office 2007
    Posts
    77

    Smile Excel Macro to Format all Worksheets in Multiple WB in a folder based on Given Criteria

    Hi excelforum Experts,

    I have these monthly reports exported from our client system in a form of excel however, there are colors and other irrelevant formats in each worksheets that I want to be removed and formatted. I have four to five worksheets per workbook (and about 32 workbooks in one folder).

    I am wondering if there could be someone that could help me come up with an excel macro that will automate the process based on the given criteria. Normally, all workbooks are saved in one folder and its file path will be pasted on the macro template. I have attached two (2) workbooks here as references. The first one will be the tool that has button on it named 'Automate' and the other workbook is the sample raw data with the desired output on it.

    The following criteria should run after I pasted the 'File Path' of the workbooks to be formatted and clicking the 'Automate' button:

    1.) The macro will automatically go to the file path given and open each workbook.
    2.) In each workbook, select all cells and remove all colors.
    3.) The following cells should be converted into 'Comma Style' format: (B7:D37, F7:F14, B38:B47, L7:L36, F21, F24, F27, F30, F33, F36 and F39).
    4.) The following cells should be converted into 'Number' format first and converted into 'Percent' format: (G7:K36, M7:M36 and C38:C47).

    The criteria above should be applied to each worksheets in all workbooks.

    Any inputs and ideas will be much appreciated. Thank you for helping me!


    Warmest regards,
    Arnel
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: Excel Macro to Format all Worksheets in Multiple WB in a folder based on Given Criteri

    This macro loops trough the files in the selected directory and copies the format on the template to the file. It assumes that all the files have exactly the same layout as the template.

    I limited the scope of the files to be tested for the purpose of this test. Change this line
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    03-01-2017
    Location
    Manila, Philippines
    MS-Off Ver
    MS Office 2007
    Posts
    77

    Re: Excel Macro to Format all Worksheets in Multiple WB in a folder based on Given Criteri

    Hi dflak,

    Thank you for taking time in answering my post and I appreciate your comments inside the module which gave me additional ideas on how each code works.

    I tried using the attached workbook and it really works except for the other worksheets (I have four to five worksheets per workbook). I appreciate if the macro could also loops across all worksheets in all workbooks and yes, they have the same layout.

    Warmest regards,
    Arnel

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: Excel Macro to Format all Worksheets in Multiple WB in a folder based on Given Criteri

    Fortunately, this did not take a lot of code changing. Once I opened a workbook to be formatted, all I had to do was loop through the sheets in the workbook and apply the code.

    As for comments. It's my opinion that comments be Rule #1 on every book on programming. In fact, I often write the comments before I write the code to tell myself what I have to do. Then I fill in the code and then I go back to fill in how I did what I did and sometimes why I did what I did. You'll be amazed about how much you forget even in a couple of weeks, much less a couple of years.

+ 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. Replies: 9
    Last Post: 04-05-2016, 03:45 AM
  2. Conditional format based on multiple criteria macro
    By sokeefe14 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-08-2015, 09:00 AM
  3. Replies: 3
    Last Post: 05-01-2014, 01:17 PM
  4. Macro to copy rows from multiple worksheets based on criteria in range
    By guidovdn in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 11-14-2013, 01:21 PM
  5. Unique Copy and Paste Macro - Multiple Worksheets Based on IF (AND) criteria
    By dwalt75 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-16-2013, 04:49 PM
  6. Replies: 5
    Last Post: 10-03-2012, 09:36 AM
  7. Excel Macro/ VBA that can hide rows based on multiple criteria
    By hody in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2012, 09:04 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