+ Reply to Thread
Results 1 to 13 of 13

Help Modify Copy and Rename a Sheet Multiple Times

  1. #1
    Forum Contributor
    Join Date
    01-15-2015
    Location
    philippines
    MS-Off Ver
    Excel 365
    Posts
    116

    Help Modify Copy and Rename a Sheet Multiple Times

    Hi Guys, I have a worksheet that has the following tabs:

    1. Template
    2. List

    The Template tab is like the base tab.
    The List tab has a list of numbers in column A that starts in row 2. Row 1 contains the header. The items in the List tab varies.

    What the worksheet does are as follows:
    1. Duplicate the Template tab to as many times as the number of items there are in the List tab (starting in row 2).
    2. Each new tab should is renamed according to the values from the List tab

    So if there are 3 items on the List tab like, 123,456, and 789. The new duplicate tabs are named as 123, 456, and 789.
    The VBA on the worksheet is able to do that. However, I would like to make additional changes.

    1. After a new duplicate is made and renamed, whatever the name of the new duplicate tab should also be written/pasted "as values" in cell C2.
    So from the same example as above, if the new duplicate tab is renamed into 123, the number 123 should also be written/pasted "as values" in cell C2.
    2. If the name of a newly duplicated tab already exists, a messagebox would appear and say something then stops and exits the sub.

    The code is show below.

    Please Login or Register  to view this content.
    Last edited by richardking; 03-22-2019 at 01:41 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    .
    It appears your macro does everything you require ... as is.
    Was there something else you were seeking or did you post this for the benefit of others needing a macro
    to create duplicate sheets ?

  3. #3
    Forum Contributor
    Join Date
    01-15-2015
    Location
    philippines
    MS-Off Ver
    Excel 365
    Posts
    116

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    Hi Logit,

    Its missing the part where I mentioned:

    However, I would like to make additional changes.

    1. After a new duplicate is made and renamed, whatever the name of the new duplicate tab should also be written/pasted "as values" in cell C2.
    So from the same example as above, if the new duplicate tab is renamed into 123, the number 123 should also be written/pasted "as values" in cell C2.
    2. If the name of a newly duplicated tab already exists, a messagebox would appear and say something then stops and exits the sub.
    I am hoping someone could help me with that.
    Last edited by richardking; 03-22-2019 at 01:41 PM.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    .
    The only change I made to your macro was adding the "Exit Sub" towards the bottom and changed the range from
    A1 to A2.

    The remainder of the macro runs as you have described in your post. So ... I am missing something from your description.

    Please reword.

    Download sample workbook : https://www.amazon.com/clouddrive/sh...FPSCYZ9a7HJ1vk

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

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    Below this line
    Please Login or Register  to view this content.
    add this line
    Please Login or Register  to view this content.

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    .
    Ahh .. I see what you are saying now. Didn't look closely enough.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-15-2015
    Location
    philippines
    MS-Off Ver
    Excel 365
    Posts
    116

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    Hi Logit, thank you. Your solution works, except for the part wherein if there's an error due to a duplicate name, it would still create a new tab.
    I also forgot to mention, if I make a filter of the list, it would still create the same number of duplicate tabs. Though, I have already thought of a solution like creating and temp sheet then deleting that after.
    However, if there's a way to skip creating a temp tab, I think it would be better.

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    .
    Ok ... will you consider taking a different approach ? Complete a search of Column A of the LIST sheet and delete any dupes.
    Then run the macro for creating sheets.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    01-15-2015
    Location
    philippines
    MS-Off Ver
    Excel 365
    Posts
    116

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    That's a good approach. However, it will still create a new duplicate tab, though with a generic name, if an error occurs.
    It would still create the same number of duplicate tabs regardless if you filter the list or not.

  10. #10
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    .
    Let's change macros again :

    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    01-15-2015
    Location
    philippines
    MS-Off Ver
    Excel 365
    Posts
    116

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    I really appreciate you taking the time in writing those codes. Your new macro was certainly able to stop and end the sub when there is a duplicate name without creating the unnecessary duplicate tab.
    It's the list when its filtered that's left. I, however, have drafted an incomplete code wherein it would copy the filtered list, create a temp sheet, then make that temp sheet as the base for the names and number of duplicate tabs.
    Then delete that temp sheet at the end. The rest of the codes are your codes.

  12. #12
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    .
    Just so long as you have the final product you were seeking. If it all works .... it is all good.

    Anything else or are you good to go ?

  13. #13
    Forum Contributor
    Join Date
    01-15-2015
    Location
    philippines
    MS-Off Ver
    Excel 365
    Posts
    116

    Re: Help Modify Copy and Rename a Sheet Multiple Times

    Yes it is. Thank you so much.

+ 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] Help to rename then copy multiple sheet from another WB
    By sbv1986 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2018, 08:52 AM
  2. [SOLVED] Duplicate sheet multiple times and rename each wcomma separated string in cell
    By michellepace in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2017, 02:13 AM
  3. Replies: 9
    Last Post: 03-28-2017, 08:30 PM
  4. [SOLVED] VBA to Multiple Copy and Paste Sheet then Rename them with unique name
    By ajimieta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-15-2017, 09:04 PM
  5. [SOLVED] Copy a sheet, rename it by value in range then export product to new workbook and rename
    By MagicMan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2015, 07:24 PM
  6. Replies: 0
    Last Post: 06-28-2014, 02:26 PM
  7. [SOLVED] Copy sheet to new file and rename 52 times one per week
    By Greaser2k in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2012, 03:53 PM

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