Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Protecting Worksheets from Deletion.

Protecting Worksheets from Deletion

by Allen Wyatt
(last updated January 2, 2016)

4

Chris has a workbook composed of two control worksheets that contain setup data. The workbook's user runs macros that create many new worksheets in the workbook. The user then deletes any unwanted worksheets. Chris wants to make sure that the two control worksheets aren't deleted by mistake.

This can be accomplished, to some extent, by protecting the structure of the workbook, as described in other ExcelTips. This protects the workbook structure from being changed, such that the user can't add or delete worksheets. Since you want the user able to add and delete worksheets, you'd need to make two changes to how the workbook is used:

  • Modify the macro that adds worksheets so that it removes the workbook protection before adding the sheets and then reinstates the protection after the sheets are added.
  • Add a macro function that deletes worksheets. The macro could check to make sure that the user isn't trying to delete the control worksheets. If it is OK for the user to delete a particular worksheet, the macro would remove workbook protection, delete the sheet, and then reinstate the protection.

Another approach is to create duplicates of the control sheets in the workbook. Make the worksheets hidden, which will protect them to a degree. Your macros could then check to see if the non-hidden control sheets were deleted. If they were, then the macro could create another control sheet by copying the hidden version of the control sheets.

Still another approach is to modify the macro that currently adds a bunch of worksheets to the workbook. The modification would create a "backup" workbook that contains the controls sheets. Later, before closing the workbook, a macro can be invoked that checks for the control sheets. If they are not present, then the macro copies them from the backup workbook. If they are present, then the backup workbook can be deleted.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11651) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Protecting Worksheets from Deletion.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Fixing Mismatched Bullets and Numbers

When you format bulleted lists or numbered lists, you may be surprised if some of the bullets or numbers don't match the ...

Discover More

Allowing for Words that Contain Numbers

When Excel does a spell-check of the information in a worksheet, you may want it to ignore words that contain numbers. ...

Discover More

Transposing Table Contents

When you transpose information, it is essentially "rotated" in a direction. If you transpose the information in a table, ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Limiting Input by Time of Day

Excel provides some great tools that allow you to limit what is entered into a worksheet. This tip looks at how those ...

Discover More

Using a Protected Worksheet

If you have a worksheet protected, it may not be immediately evident that it really is protected. This tip explains some ...

Discover More

Enabling Editing Erases Worksheet

If you receive a protected worksheet that you want to edit, how do you proceed if you try to unprotect the worksheet and ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is eight minus 3?

2016-01-05 06:29:09

Petros

@Jennifer, You are welcome!


2016-01-04 10:50:51

Jennifer Thomas

@Petros: Thanks for the link to protection myths -- that was a very interesting and useful article!


2016-01-04 03:50:57

Doru Achihai

Hi Allen,

Happy New Year.
One other way to protect the sheets is to set the property Worksheet.Visible to 2 (xlSheetVeryHidden). This can be done in the Properties window, selecting the sheet of the respective project.
With this property, the sheet can not be unhidden by users unless they are experts - which means they already know what they are doing :)

Kind regards,
Doru


2016-01-02 05:27:27

Petros

I find it quite puzzling that Microsoft has opted to alert users through the standard user interface that very hidden sheets exist in workbooks. This tip has been tested in all Excel versions with a Backstage view such as 2010, 2013 and 2016. If you are a workbook developer and don't want users to view the sheets you have hidden via VBE, please do not password protect them!

Read more:

http://www.spreadsheet1.com/excel-protection-myths-busted.html


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.