+ Reply to Thread
Results 1 to 11 of 11

If worksheet name doesn't exist from list then create using template

  1. #1
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    If worksheet name doesn't exist from list then create using template

    Hi everyone,

    I have a list of cell values from worksheets("Sum").Range("J17") to end(xltoleft)

    There are worksheets in my workbook that are named using the values in the range above & "ABC"

    What I'm trying to do is have a macro which will loop through range listed above, and if it does not fine a corresponding worksheet in the workbook with one of those values & "ABC" a new worksheet will be created using a worksheet called ABC Template, the sheet will be renamed using the extra value in range & "ABC", and the extra value will be place in cell B10 in the new worksheet.

    Example:

    J17 = 123, J18 = 234, J19 = 354

    In the workbook, there are two worksheets

    123ABC, 234ABC, but no 345ABC

    The macro will see this missing worksheet, create a new one using ABC Template, rename the worksheet as 345ABC, and place the value 345 in cell B10 of the new worksheet.

    Any ideas?

    Thanks!!

  2. #2
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: If worksheet name doesn't exist from list then create using template

    This is the code I have so far:

    Please Login or Register  to view this content.
    So right now MyCell is the cell value & ABC, i.e. 123ABC. However, when I run this code the ABC Template only copies without changing the name to say 345ABC and it seems to want to create an ABC Template copy for every cell in the MyRange. I'm guessing its because its not renaming the sheet properly.

    Any ideas?

    Thanks!!

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: If worksheet name doesn't exist from list then create using template

    Hi Groovicles

    Wanna give this a try:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 04-18-2017 at 02:12 PM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: If worksheet name doesn't exist from list then create using template

    Hi sintek,

    Thanks very much for your code. It sure seems to work my faster than the one I put together. However, when I run the code it only creates a new worksheet for the last cell in the range("J17").end(xltoleft) range. The code needs to create worksheets for any cells in that range which don't already have a worksheet in the workbook.

    Any ideas?

    Thanks!

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: If worksheet name doesn't exist from list then create using template

    Hi Groovicles, back to drawing board lol

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: If worksheet name doesn't exist from list then create using template

    Here you go:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: If worksheet name doesn't exist from list then create using template

    Here's what I have so far. This code does what its supposed to do. However, it takes a bit of time to run through because it creates copies of the SUM worksheets and then deletes the copies while retaining the new SUM worksheets. It would be a big help if it would just create the worksheets based on a comparison between the list and the existing worksheets rather than running through them all.

    Please Login or Register  to view this content.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: If worksheet name doesn't exist from list then create using template

    Here you go
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: If worksheet name doesn't exist from list then create using template

    That's it! Perfect! Thanks sintek.

  10. #10
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: If worksheet name doesn't exist from list then create using template

    Try this

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  11. #11
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: If worksheet name doesn't exist from list then create using template

    Awesome, glad it worked out....

+ 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. Create folder in list if it doesn't exist
    By ChrysanthiM in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-22-2016, 12:04 PM
  2. Create a Folder if it doesn't not exist.
    By Lucholac44 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2016, 08:38 AM
  3. How to delete a worksheet if it doesn't exist in a list
    By iamrickdeans in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2013, 09:46 AM
  4. [SOLVED] Look for a File and create one if it doesn't exist
    By Titansmasher in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-08-2012, 07:43 PM
  5. Create a new Sheet if it doesn't exist?
    By nbaj2k in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-28-2006, 06:49 PM
  6. Replies: 4
    Last Post: 06-18-2006, 01:10 PM
  7. [SOLVED] Create Folder If It Doesn't Exist
    By Neutron1871 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-05-2005, 09:06 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