+ Reply to Thread
Results 1 to 7 of 7

prevent deleting worksheet, set as xlVeryHidden enstead

  1. #1
    Registered User
    Join Date
    02-16-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    5

    prevent deleting worksheet, set as xlVeryHidden enstead

    I would like to "Archive" any worksheet that has data beyond row 14 when a user tries to delete the sheet.

    I know in the ThisWorkbook code, I can edit what happens when a worksheet is added, by editing the sub "Workbook_NewSheet" and I was wondering if there is a way to do something similar for when sheets are deleted.

    I know, usually, when a sheet is deleted, a confirmation message is shown, asking if the user is sure they would like to delete the sheet. I would like to avoid showing that message, and show my own, asking if the user would like to "Archive" the sheet enstead. If they select yes, I would like set the sheet as xlveryhidden, and rename it to nameArchived. If no is selected, then delete message may be shown.

    Any suggestions?
    Last edited by MagicWIU; 02-27-2009 at 07:33 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: prevent deleting worksheet, set as xlVeryHidden enstead

    I don't believe there is a delete event that you can use. If you open the VB Editor, click on ThisWorkBook & set the left hand drop down to WorkBook you can see a list of events available
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    02-16-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: prevent deleting worksheet, set as xlVeryHidden enstead

    hahaha thanks, this may have helped... after checking what you said... i noticed Sheetdeactivate.... is one of the options. Under excel's help is this little code:
    Please Login or Register  to view this content.
    which shows a message whenever a sheet is deactivated. It also happens to show the message right before a sheet is deleted.

    This may help, but it still doesn't solve my question. I don't really want my archive message showing every time someone views a new worksheet.
    Any suggestions on limiting the message to only deleted workshets?

  4. #4
    Registered User
    Join Date
    02-16-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: prevent deleting worksheet, set as xlVeryHidden enstead

    BUMP Not solved yet

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: prevent deleting worksheet, set as xlVeryHidden enstead

    Protect the workbook (which prohibits deleting sheets) then add a macro that archives the sheet.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    02-16-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: prevent deleting worksheet, set as xlVeryHidden enstead

    I thought briefly about protecting the workbook, but I still want the user to be able to delete it, if necessary.

    I would like the user to be able to click the same "delete worksheet" buttons or right clicks, I just want to catch it before its deleted.

    Is there any way to force the cancel button to be pressed when a user deletes a worksheet? If there were, I could run a macro at that point...

    any ideas?

  7. #7
    Registered User
    Join Date
    02-16-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: prevent deleting worksheet, set as xlVeryHidden enstead

    Was unsuccessful with this for days. I talked to a friend about it and he found an answer here

    http://www.mrexcel.com/forum/showthr...86#post1855786

    there are a few methods shown. First one that worked was hiding the command button for deleting a worksheet. Then creating a duplicate command button with your own macro and placing the button in the same place as the original button. This method works very well on previous versions of office.

    In 07 The ribbons are used instead of the original menus therefore the first method would not work with the command buttons within the ribbons. So there is a workaround for 07. The link above has all the information you would need if you were trying to do something similar to my project.

    Enjoy

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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