+ Reply to Thread
Results 1 to 5 of 5

Prevent Users From Deleting Worksheets

  1. #1
    Forum Contributor
    Join Date
    05-17-2007
    Location
    Michigan, US
    MS-Off Ver
    2007
    Posts
    111

    Prevent Users From Deleting Worksheets

    I am trying to bombproof this spreadsheet that I have been working on to the point where it would be very difficult for my co-workers to mess it up.

    I was suprised to find out that even though my worksheets are protected, that I can simply right-click on the worksheet tab and choose Delete.

    I looked in both the Workbook and Worksheet event list and there is nothing there like "Before Delete", etc.

    Is there anyway that I can prevent users from deleting Worksheets? If so, I would also like to prevent them from Inserting them as well.

    I can't use the Protect Workbook Structure feature because it won't allow worksheet tabs to be renamed. I have VBA code that automatically renames the worksheet tab name based on the value of a cell in that worksheet and I need that functionality.

    Thanks, Spence
    Last edited by Spencer; 03-28-2011 at 03:39 PM. Reason: Clarification about not being able to use Protect Workbook Structure

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

    Re: Prevent Users From Deleting Worksheets

    Your code can unprotect the workbook, do what it needs to do, and then reprotect it.

    See Help for the Protect method.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Prevent Users From Deleting Worksheets

    I'm sure shg could clean this code up for you, workbook attached, passwords "asd"
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    05-17-2007
    Location
    Michigan, US
    MS-Off Ver
    2007
    Posts
    111

    Re: Prevent Users From Deleting Worksheets

    Quote Originally Posted by shg View Post
    Your code can unprotect the workbook, do what it needs to do, and then reprotect it.

    See Help for the Protect method.
    Thanks, I didn't even think of trying that. I'll give that a shot tomorrow, as my brain is too burned out on VBA tonight.

    You guys are just as amazing as Excel itself.

    Thanks for all your help,
    Spence

  5. #5
    Forum Contributor
    Join Date
    05-17-2007
    Location
    Michigan, US
    MS-Off Ver
    2007
    Posts
    111

    Re: Prevent Users From Deleting Worksheets

    Adding the code to unprotect and then reprotect the workbook seems to work fine. I don't know what else this will affect, but as far as the autmatic renaming of my worksheet tab names, it works great.

    Thanks, Spence

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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