+ Reply to Thread
Results 1 to 3 of 3

How to replace Excel's delete warning (for one visible worksheet) with custom message?

  1. #1
    Registered User
    Join Date
    05-23-2011
    Location
    Ballston Spa, NY
    MS-Off Ver
    Excel for Office 365
    Posts
    18

    How to replace Excel's delete warning (for one visible worksheet) with custom message?

    Hello,

    I have a workbook that has 4 hidden worksheets, plus 1 or more worksheets unhidden and available to the user. I'm using worksheet protection but not workbook protection. Users are free to copy and delete worksheets, but there should always be one "user" worksheet present, in addition to the 4 hidden worksheets. Fortunately, a built-in Excel requirement almost addresses this: when user tries to delete the last visible worksheet, the Excel warning comes up, "A workbook must contain at least one visible worksheet. To hide, delete, or move the selected sheets(s), you must first insert a new sheet or unhide a sheet that is already hidden".

    Unfortunately, that warning tips the user off that there are hidden worksheets. I have not instituted "very hidden" or other tricks to keep them from finding the hidden worksheets (which are protected at least) - my users are not advanced in Excel and I don't think will go exploring. But this message will encourage them to. Also, if they do unhide at least one other, they'll be able to go ahead and delete the last user worksheet, and they shouldn't be able to.

    How can I replace the standard message with a message of my own? (e.g., "You must leave at least one user worksheet available in this workbook. Please click Cancel.") I think that requires error handling targeting that message, but as a novice with VBA I don't understand whether I can place such handling in the workbook module, or how to implement.

    Thank you for any direction on this.

    Steve
    Last edited by Steve Rutkey; 03-29-2020 at 12:01 PM.

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

    Re: How to replace Excel's delete warning (for one visible worksheet) with custom message?

    Quote Originally Posted by Steve Rutkey View Post
    I have not instituted "very hidden" or other tricks to keep them from finding the hidden worksheets (which are protected at least) - my users are not advanced in Excel and I don't think will go exploring.
    To me, hiding the sheets xlVeryHidden would be the most simple solution. It's an easy thing to do. They are not going to find them unless they try hard.
    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
    05-23-2011
    Location
    Ballston Spa, NY
    MS-Off Ver
    Excel for Office 365
    Posts
    18

    Re: How to replace Excel's delete warning (for one visible worksheet) with custom message?

    AlphaFrog,

    Thank you for your guidance. I hadn't used very hidden before (only read about it while looking for other things)...but you are right, it is very easy to use. I had macros that were setting visibility to False and changing those to xlSheetVeryHidden does the job I needed. Thank you for the quick response! I will mark as solved.

    Steve

+ 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] How to Delete a Worksheet w/o warning
    By Gandalf2524 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-19-2014, 11:01 AM
  2. VBA Code warning message ANY empty blank cell Entire worksheet
    By RyanTExcel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-25-2013, 01:45 PM
  3. [SOLVED] How to pop up a warning message before any Excel automatic update link reminder message
    By billj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2013, 10:41 AM
  4. replace VBA run-time error message with custom message
    By BEEJAY in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-14-2006, 11:05 AM
  5. Replace Excel Message w/Custom Message
    By Kevin R in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2006, 11:15 AM
  6. Replies: 2
    Last Post: 08-09-2005, 12:05 PM
  7. [SOLVED] Worksheet has to set to visible as it is not visible after saving and closing Excel by VB.
    By Oscar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-21-2005, 06:05 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