+ Reply to Thread
Results 1 to 8 of 8

Duplicate entire workbook into 3 copies and leave only specific sheets in the copies

  1. #1
    Registered User
    Join Date
    04-21-2016
    Location
    Israel
    MS-Off Ver
    Office 2016
    Posts
    52

    Duplicate entire workbook into 3 copies and leave only specific sheets in the copies

    Hi,

    I'll be happy if you could help me in a quite simple action to write in VBA code. I tried many ways and didn't succeed to complete the needed action (only partially) due to knowledge gaps in VBA...

    I have a Master Workbook containing 5 sheets:
    Sheet #1-> Main
    Sheet #2 -> Subject A
    Sheet #3 -> Subject B
    Sheet #4 -> Subject C
    Sheet #5 -> Help

    I need entire workbook to be duplicated 3 times and after duplication VBA will do the following actions in each copy:

    Copy 1 - Name of workbook need to be: Subject_A >>> Only 'Subject A' sheet remains as is. 'Help' sheet need to be hidden. All other sheets need to be deleted.
    Copy 2 - Name of workbook need to be: Subject_B >>> Only 'Subject B' sheet remains as is. 'Help' sheet need to be hidden. All other sheets need to be deleted.
    Copy 3 - Name of workbook need to be: Subject_C >>> Only 'Subject C' sheet remains as is. 'Help' sheet need to be hidden. All other sheets need to be deleted.

    I need that the duplication will be done into the same folder (!) as of the master workbook, with no need to indicate the path of the folder.

    Macro should run only from Master Workbook.

    Master Workbook need to stay open. All 3 copies need to be close.

    Somehow I can't attach anything to my thread...

    *** Important note: I need the workbook to be entirely copied and then to the delete & hide actions in the copies, and NOT to copy only the requested sheets into the copies (even if action will be longer and less efficient),
    since there are Macro buttons that directing to the master file (not as should be) and conditional formatting that is totally disrupted...

    Thanks in advance

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

    Re: Duplicate entire workbook into 3 copies and leave only specific sheets in the copies

    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.

  3. #3
    Registered User
    Join Date
    04-21-2016
    Location
    Israel
    MS-Off Ver
    Office 2016
    Posts
    52

    Re: Duplicate entire workbook into 3 copies and leave only specific sheets in the copies

    Hi Alphafrog,

    Thanks a lot for your quick answer and code!
    The code does the required action perfectly, exactly as I wanted, except one thing...
    In my original workbook, the 3 "Subject..." sheets contain also few Macro buttons that their VBA code is written in one of the modules in the original master file.
    After your VBA code makes the required selective copies, when I open each one of the copies and try to activate their macros, they won't run and I get an error message that these macro are not available.
    I don't know how to solve this issue... Can you please advise?

    Thanks a lot

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Duplicate entire workbook into 3 copies and leave only specific sheets in the copies

    Rule 08: Cross-posting Without Telling Us

    Your post does not comply with Rule 8 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question. If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    If you have less than 10 posts, do not try to copy and paste the link. Instead, type the link out in your thread.

    No further help to be offered, please, until the OP has complied with this request.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    04-21-2016
    Location
    Israel
    MS-Off Ver
    Office 2016
    Posts
    52

    Re: Duplicate entire workbook into 3 copies and leave only specific sheets in the copies

    Sorry, I didn't know that I'm doing something against forums rules.
    I don't understand what I should do in order to fix it. I tried to delete my post in the other forum and didn't succeed...
    Moreover, can you please explain this sentence: No further help to be offered, please, until the OP has complied with this request.
    What is OP? I need the forum's help urgently... Please.

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

    Re: Duplicate entire workbook into 3 copies and leave only specific sheets in the copies

    Liorc, you are the OP (original person). You don't have to delete anything. You are allowed to cross-post, but when you do, state you have cross-posted and provide link(s) to the other posts. The idea being that no one likes to answer a question that has been answered elsewhere. It's just considerate to keep all parties informed. It's also nice, but not required, that if you do get an answer elsewhere, to state it here and close the thread.

    So all you have to do is state that it's cross-posted and provide links.

  7. #7
    Registered User
    Join Date
    04-21-2016
    Location
    Israel
    MS-Off Ver
    Office 2016
    Posts
    52

    Re: Duplicate entire workbook into 3 copies and leave only specific sheets in the copies

    OK, Thanks a lot.

    Now, per your request, I tried to add a link to my other post but got an error message:
    The following errors occurred with your submission
    You are not allowed to post any kinds of links, images or videos until you post a few times.

    ???

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

    Re: Duplicate entire workbook into 3 copies and leave only specific sheets in the copies

    Read post #4 again. The instructions are complete.

+ 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] Need help with Macro that copies specific data from one workbook to another!!!
    By crewdog463 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-12-2017, 01:34 PM
  2. Replies: 0
    Last Post: 07-01-2015, 03:06 PM
  3. Replies: 0
    Last Post: 07-01-2015, 01:59 PM
  4. Replies: 5
    Last Post: 05-05-2015, 12:42 PM
  5. Replies: 0
    Last Post: 07-23-2012, 06:22 AM
  6. Replies: 3
    Last Post: 04-16-2009, 10:24 AM
  7. Workbook saving repeated duplicate copies.
    By Gavin1855 in forum Excel General
    Replies: 3
    Last Post: 06-26-2008, 09:17 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