+ Reply to Thread
Results 1 to 3 of 3

Save WorkSheets to Multiple Folders based on the WorkSheet Name

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Save WorkSheets to Multiple Folders based on the WorkSheet Name

    I have a Workbook containing a Summary Tab, a Hidden Worksheet and any number of worksheets named X00120, X00121, X00125 and so on (see attached). These worksheets all include cells with formulas.

    I then have a folder containing subfolders that use the names of the worksheets. There will be more folders than there are worksheets, so my folder structure looks like this:

    Exports.jpg

    For each Worksheet named X00123, X00124, X00125 and so on, I need to do the following with a single macro:
    1. Copy and Paste Values to remove the formulas on these sheets only.
    2. Save each Worksheet (excluding the Summary sheet and the Hidden sheet) as a both a .xlsx and a .pdf file to its respective folder, so X00123 will be automatically saved to the folder X00123, X00124 will be saved to the folder X00124 and so on.
    3. Prefix each filename with 'Summary Expenditure Report', so the files saved in each folder should be named 'Summary Expenditure Report - X00123', 'Summary Expenditure Report - X00124' and so on for both the .xlsx and the .pdf versions


    I need the option to run the macro from a button on the summary sheet so it will save all the files in one go automatically without asking the user (although the user should be asked if they want to overwrite the file if it already exists) and also the option to have a button on each worksheet that achieves the same thing but only for the active sheet.

    Is this possible? and it is possible to achieve in a single macro or would this require two different macro's, one to save all sheets and a second to save individual sheets?

    Many thanks
    Attached Files Attached Files
    Last edited by HangMan; 10-24-2015 at 09:58 AM.
    Thanks,
    HangMan

    You can say "Thank you!" by clicking Add Reputation below the post.
    Please, mark your thread [SOLVED] if you are happy with the solution.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Save WorkSheets to Multiple Folders based on the WorkSheet Name

    Hi Hangman,

    See the attached file, which is a modified copy of your workbook. Instead of asking for OVERWRITE, I used two CommandButtons on each sheet, OVERWRITE and NO OVERWRITE. If what I did is not acceptable, please let me know what you want.

    I added code to create the folders, because I needed it to test the code.

    Important Code Excerpts follow:
    Please Login or Register  to view this content.
    Lewis
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Save WorkSheets to Multiple Folders based on the WorkSheet Name

    Hi Lewis,

    OMG, thanks for this, it must have taken you hours! I now need to get my head around each element of the code and understand it to see which elements are doing what...

    Can I check it out and come back to you with any questions, which I'm sure I'm going to have...

    Many thanks

+ 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. [SOLVED] Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-09-2015, 02:56 PM
  2. Excel worksheet splitting into multiple worksheets with folder save
    By utechtj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2014, 02:36 AM
  3. Replies: 0
    Last Post: 12-04-2012, 01:01 PM
  4. [SOLVED] VBA to save multiple worksheets as separate CSV files using name of worksheet
    By Yg74 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-20-2012, 10:55 AM
  5. VBA to save multiple worksheets as separate CSV files using name of worksheet
    By titushanke in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-20-2012, 08:08 AM
  6. save a worksheet to 3 different folders
    By nnguys in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-07-2012, 12:56 PM
  7. Can i save the Items to multiple folders
    By jesika in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 03-07-2009, 05:52 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