+ Reply to Thread
Results 1 to 7 of 7

Creating new sheet based on user input - old sheets get deleted by mistake

  1. #1
    Registered User
    Join Date
    03-06-2024
    Location
    London, England
    MS-Off Ver
    Microsoft 365 for Enterprise
    Posts
    3

    Creating new sheet based on user input - old sheets get deleted by mistake

    Hi all,

    I'm currently trying to use a user input to name a duplicate sheet based off a 'template sheet' within the same workbook, then populate cell B11 of the duplicate sheet with the user's input. This seemed to work fine, however, after doing 4 duplicate sheets, some of the new sheets get deleted/renamed and hidden? not sure where i'm going wrong here. Any help would be greatly appreciated! Let me know if you need more information. Thanks




    Please Login or Register  to view this content.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Creating new sheet based on user input - old sheets get deleted by mistake

    Hi there,

    Without sight of your workbook it's difficult to know exactly what is/is not happening.

    Please Login or Register  to view this content.
    When you hide a worksheet, you don't have full control over which worksheet then becomes the active worksheet. In most cases the NEXT (i.e. the next tab on the right-hand side) worksheet becomes active, however if you hide the last (i.e. rightmost) worksheet, the PREVIOUS worksheet becomes active. Something like this might help to explain any inconsistent results you're experiencing.

    Hope this helps.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    03-06-2024
    Location
    London, England
    MS-Off Ver
    Microsoft 365 for Enterprise
    Posts
    3

    Re: Creating new sheet based on user input - old sheets get deleted by mistake

    Hi Greg,

    Really appreciate the response! Thanks

    I've attached an example copy of the spreadsheet I'm working on. There's two template versions, one I've hidden the template for and removed the visible = xlSheetHidden lines (Template 1) and the other I haven't (Template 2). I hope this helps clarify what is/is not happening. How would I be able to reference the newly created sheet within the code? Ideally I would like the template sheets to be hidden, but not sure if this is possible without using sheet indexing.
    Attached Files Attached Files
    Last edited by dylanherri97; 03-06-2024 at 01:24 PM.

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Creating new sheet based on user input - old sheets get deleted by mistake

    Possibly...
    Please Login or Register  to view this content.

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Creating new sheet based on user input - old sheets get deleted by mistake

    Hi again,

    Unfortunately there are several basic errors in the code you posted originally, e.g.:

    Please Login or Register  to view this content.
    The compiler would have identified these errors if you had placed "Option Explicit" as the first line in the CodeModule - you should ALWAYS do this.

    Also, you should not include open-ended "On Error Resume Next" statements - these can produce VERY strange/dangerous results! If you need to use them, you should always restore error handling as soon as possible by means of an "On Error GoTo 0" statement.


    See if the attached version of your workbook does what you need - it uses the following code:

    Please Login or Register  to view this content.
    Worksheets CAN be copied (as hidden worksheets) when their Visible property is set to "Hidden" - it's only when that property is set to "VeryHidden" that they can't be copied.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files
    Last edited by Greg M; 03-06-2024 at 09:18 PM. Reason: Extra highlighting added

  6. #6
    Registered User
    Join Date
    03-06-2024
    Location
    London, England
    MS-Off Ver
    Microsoft 365 for Enterprise
    Posts
    3

    Re: Creating new sheet based on user input - old sheets get deleted by mistake

    Hi Greg,

    Thank you very much and thanks for explaining some of the more egregious errors in my original code, it makes a lot of sense now!

    Your updated template seems to work perfectly and is incredibly easy to add new templates etc as well.

    Thanks again

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Creating new sheet based on user input - old sheets get deleted by mistake

    Hi again,

    Many thanks for your feedback.

    You're welcome - glad I was able to help.

    Regards,

    Greg M

+ 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. Creating an input sheet that outputs on to different sheets.
    By Sheamau5 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-15-2014, 08:05 AM
  2. Please Help with Copy/Paste and creating sheets depending on user input
    By rrstull in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-06-2013, 05:43 AM
  3. Creating varied templates based on user input when opened?
    By Set in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-22-2012, 05:46 PM
  4. Creating a spreadsheet based upon user data input
    By kriebelken in forum Excel General
    Replies: 0
    Last Post: 08-01-2012, 04:55 AM
  5. [SOLVED] Refreshing/Recalculating Sheets based on user input or switching between sheets
    By SonOfOdin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2012, 09:48 PM
  6. Creating summation formula based on user input.
    By gshock in forum Excel General
    Replies: 2
    Last Post: 01-08-2009, 09:49 AM
  7. Creating Input box that grap data based on user answer
    By salooha in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2006, 07:30 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