+ Reply to Thread
Results 1 to 14 of 14

Tab Duplication and Renaming based off a list

  1. #1
    Registered User
    Join Date
    09-23-2022
    Location
    Houston, Texas
    MS-Off Ver
    365
    Posts
    64

    Tab Duplication and Renaming based off a list

    What i am trying to do is be able to press a control button that will
    1) Copy/Duplicate a "master" tab, example Master > Copy > Master (2)
    2) Rename the duplicate tab, example Master (2) > New Name

    The new name come from a list also within the same workbook.

    I have come across methods just simply googling that do create tabs based off a list, but not really one for duplicating a tab and then renaming.

    I'm hoping there is an excel GOAT/Guru that may provide some info.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Tab Duplication and Renaming based off a list

    Please Login or Register  to view this content.
    Experience trumps academics every day of the week and twice on Sunday.

  3. #3
    Registered User
    Join Date
    09-23-2022
    Location
    Houston, Texas
    MS-Off Ver
    365
    Posts
    64

    Re: Tab Duplication and Renaming based off a list

    Jolivanes, I was not able to get the script to run. It did copy the "master" tab but then fails. Any thoughts?
    See file attached.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Tab Duplication and Renaming based off a list

    I have not downloaded your attachment from Post #3 because the code worked on your attachment from Post #1.
    Is it different?

    Edit. Will be back shortly. Found the error when sheets were not in workbook.
    Last edited by jolivanes; 03-21-2024 at 04:30 PM.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Tab Duplication and Renaming based off a list

    My mistake. Forgot part of the code. It worked when the sheets to be added were in the workbook already.
    This should be better. It will always add a sheet, even if they exist. It'll just adds an index value to the sheet name.
    If you want a different approach for when a sheet exist already, let us know.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-23-2022
    Location
    Houston, Texas
    MS-Off Ver
    365
    Posts
    64

    Re: Tab Duplication and Renaming based off a list

    oooooh nice @jolivanes,

    i see what you mean by adding a index if a sheet already exist

    is it possible to prevent the script from doing this? like lets say you already ran the script once and boom, done. then if you rerun the script it would not do anything since the sheets already exist.

    Now if sheets were added to the list, it would iterate through the list name and only populate those that are new, ignoring the ones that already exist?

    This would be great

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Tab Duplication and Renaming based off a list

    Yes, should not be a problem but I am on my way out of the door so it'll be later on. Maye someone else jumps in in the meantime

  8. #8
    Registered User
    Join Date
    09-23-2022
    Location
    Houston, Texas
    MS-Off Ver
    365
    Posts
    64

    Re: Tab Duplication and Renaming based off a list

    Thank you for the wisdom. In the meantime, here is my recent discover with the script. It does not run if there are hidden sheets.

    See the attached file for testing.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Tab Duplication and Renaming based off a list

    What else is going to change?
    Let us know what is needed and the circumstances, like hidden sheets.
    If you don't explain everything in a proper manner we'll be here for a week of sundays trying to get you code that works.

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Tab Duplication and Renaming based off a list

    How do you want to make sure that "1-5" (Jan 05) is not seen as a date but 5-Jan is a date?
    Maybe get used to making sure to eliminate possible problems like these.
    There are ways of doing that but in the future you're going to run into problems.
    If "1-5" and "1-2" are not meant to be dates, use an underscore instead ("1_5" and "1_2") or better yet, use something that can never be seen as a date.
    In other words, KISS (Keep It Simple).

  11. #11
    Registered User
    Join Date
    09-23-2022
    Location
    Houston, Texas
    MS-Off Ver
    365
    Posts
    64

    Re: Tab Duplication and Renaming based off a list

    Apologies for the mis-forecast of info @jolivanes. I'll do a better job at this moving forward. Thanks for letting me know!

    I only discovered this after hiding the master tab since i would not want it to be touched.
    Disregard the date. I simply added random items to the "sheetnames" to run the script and seeing if anything broke.


    This is the last bit of information that I can think of that may be relevant.

    The only issue that i am noticing is hidden tabs/sheets don't allow the renaming process. This would be the last thing that comes to mind that would make this macro run without a hitch.
    Ideally, I'd hide the master tab so that no one touches it. (I'd also have a few other non-related tabs hidden)
    Then the macro runs and copies and renames just like before.

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Tab Duplication and Renaming based off a list

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    09-23-2022
    Location
    Houston, Texas
    MS-Off Ver
    365
    Posts
    64

    Re: Tab Duplication and Renaming based off a list

    Jovalines,

    Thank you the help. This works just like i had pictured.

  14. #14
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Tab Duplication and Renaming based off a list

    Thanks for letting us know and good luck.

+ 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. repeating number list without duplication
    By Nightowel23 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2023, 11:03 PM
  2. [SOLVED] Pick from list of questions without duplication
    By kennedy1231 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-05-2017, 09:01 PM
  3. Replies: 5
    Last Post: 05-07-2014, 10:58 AM
  4. [SOLVED] Finding duplication in name list
    By bosetan in forum Excel General
    Replies: 10
    Last Post: 04-02-2013, 08:01 AM
  5. Duplication of a List
    By ajh_87 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-25-2007, 09:09 AM
  6. Replies: 1
    Last Post: 01-16-2006, 10:30 PM
  7. Remove duplication from validation list?
    By [email protected] in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-16-2006, 10:20 PM

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