+ Reply to Thread
Results 1 to 7 of 7

prevent deleting worksheet, set as xlVeryHidden enstead

Hybrid View

MagicWIU prevent deleting worksheet,... 02-18-2009, 08:36 AM
royUK Re: prevent deleting... 02-18-2009, 08:42 AM
MagicWIU Re: prevent deleting... 02-18-2009, 09:10 AM
MagicWIU Re: prevent deleting... 02-19-2009, 07:17 PM
shg Re: prevent deleting... 02-19-2009, 07:27 PM
  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:
    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
        MsgBox Sh.Name
    End Sub
    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?

+ 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