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

Protecting Worksheets from Deletion

Written by Allen Wyatt (last updated November 17, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003


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 these worksheets hidden, which protects 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 (3267) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) 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

Changing Page Margins

If your worksheet is destined to be printed, you'll need to be concerned with how it appears on the page. One layout ...

Discover More

Deleting a Footer

Excel allows you to add footers to the worksheets you create. If you decide you don't need a footer any more, here's how ...

Discover More

Finding Workbooks Containing Macros

Workbooks can contain macros, or not. It is entirely up to you whether they do or not, but at some future time you might ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Hiding and Protecting Columns

Want to hide certain columns within a worksheet so the contents are not visible to others? The answer lies in formatting ...

Discover More

Controlling Entry Order on Unprotected Cells

When you protect a worksheet, one of the benefits is that you can limit which cells can be used for data entry. How a ...

Discover More

Inserting and Deleting Rows in a Protected Worksheet

You've protected and saved your worksheet with explicit instructions that you be allowed to insert and delete rows. But ...

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}] (all 7 characters, in the sequence shown) 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 2 + 8?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.