+ Reply to Thread
Results 1 to 9 of 9

Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes

  1. #1
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2007
    Posts
    113

    Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes

    I have a macro that I use to generate new workbooks based off of the existing worksheet names.

    So, if a worksheet is named "10", a new workbook will be generated named "10.xlsx".

    However, if I have two sheets named "10[something1]" and "10[something2]", is there a way to get both of those tabs pushed into a new workbook named "10[something]"

    Essentially, the macro should be able to run through all sheets in the workbook named similary as the examples above, and perform the same save functionality.

    The code that I have below is what I am currently using to perform the single worksheet to workbook save, but would really appreciate some help on performing the aforementioned:

    Please Login or Register  to view this content.
    Thanks in advance
    Attached Files Attached Files
    Last edited by hamidxa; 01-07-2015 at 03:16 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes

    Hi hamidxa

    What do your Actual Sheet Names look like?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2007
    Posts
    113

    Re: Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes

    Quote Originally Posted by jaslake View Post
    Hi hamidxa

    What do your Actual Sheet Names look like?
    jaslake

    They would all have a 2 digit prefix followed by some name

    Real examples include:
    10Transition, 10Moved, 10Same
    11Transition, 11Moved, 11Same
    12Transition, 12Moved, 12Same
    etc.

    If there would be a way to save all of the 10-based prefix sheets as a workbook simply named "10.xlsx", or all of the 11-based prefix sheets as "11.xlsx", etc., then that would be perfect.
    Last edited by hamidxa; 01-08-2015 at 11:10 AM.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes

    Hi hamidxa

    This Code has been added to your Workbook
    Please Login or Register  to view this content.
    You'll need to modify this line as desired
    Please Login or Register  to view this content.
    The Code is called from this Procedure
    Please Login or Register  to view this content.
    Let me know of issues.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2007
    Posts
    113

    Re: Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes

    Quote Originally Posted by jaslake View Post
    Hi hamidxa

    This Code has been added to your Workbook
    Please Login or Register  to view this content.
    Let me know of issues.
    jaslake,

    As usual, you never cease to amaze!

    I am curious about one thing however.
    The new workbooks always start out with empty sheets, Sheet2 and Sheet3, (in addition to the Prefix based sheets needed).

    Is there a way to avoid creating those other Sheets (Sheet2, Sheet3) or a convenient way of getting rid of them in each of the newly created workbooks (of which there could be many)?

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes

    Hi hamidxa

    I don't have the issue you describe but it's probably something in my settings.

    Start from a clean Worksheet...only Master Worksheet.

    Try this...if it does not work as expected there is a brute force solution...add the line of Code as indicated
    Please Login or Register  to view this content.
    Let me know of issues.

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes

    Hi hamidxa

    Here it is (my settings). It's why I didn't have your issue. When my Platform creates New Workbooks, the New Workbook has ONLY one WorksheetSheets in New Book.jpg

  8. #8
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2007
    Posts
    113

    Re: Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes

    Quote Originally Posted by jaslake View Post
    Hi hamidxa

    Here it is (my settings). It's why I didn't have your issue. When my Platform creates New Workbooks, the New Workbook has ONLY one WorksheetAttachment 369263

    jaslake,

    This is perfect.
    Thank you so much for the explanation!

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Save Multiple Worksheets as New Workbooks Based on Sheet Prefixes

    You're welcome...glad I could help. Thanks for the Rep.

+ 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] Create single worksheet from multiple workbooks with 4 worksheets in each workbook
    By VKS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-11-2013, 03:35 AM
  2. Need to combine data from multiple worksheets in multiple workbooks into 1 worksheet
    By ginric99 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-30-2013, 07:58 AM
  3. [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
  4. 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
  5. Multiple workbooks and worksheets to 1 worksheet
    By marklister in forum Excel General
    Replies: 2
    Last Post: 02-07-2012, 10:24 AM

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