Please Note: This article is written for users of the following Microsoft Excel versions: 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: Inserting and Deleting Rows in a Protected Worksheet.
Written by Allen Wyatt (last updated September 22, 2020)
This tip applies to Excel 2000, 2002, and 2003
Beginning in Excel 2000, Microsoft added the capability to define what the user can do in a protected worksheet. Using the check boxes in the Protect Sheet dialog box, you can choose a wide variety of allowed actions. (See Figure 1.)
Figure 1. The Protect Sheet dialog box.
One of the actions allowed in the Protect Sheet dialog box is inserting and deleting rows and columns in a protected worksheet. This is a great feature for some types of worksheets. But there is something odd in how this feature actually works.
Let's say you create a worksheet and you protect it. In doing so, you indicate that it is OK for people to both insert and delete rows in the protected worksheet. When someone tries to insert a row in the protected worksheet, it inserts just fine. If someone tries to delete a row—even the row they just inserted—the action is not allowed; it cannot be done. What gives? You indicated in the Protect Sheet dialog that people could delete rows, but still Excel doesn't allow you to do so.
The reason seems to be tied to how Excel implements worksheet protection. Remember that protection is applied to all cells that are formatted as Locked on the Protection tab of the Format Cells dialog box. If any cell in a row you try to delete is formatted as Locked, then worksheet protection won't allow you to delete the row. If all the cells in the row have the Locked check box cleared, then the row can be successfully deleted. (See Figure 2.)
Figure 2. The Protection tab of the Format Cells dialog box.
Interestingly, the user cannot delete a row that they added because the added row inherits the cell formatting of the row above it. So, if there are any locked cells in the row above the row inserted, then the inserted row cannot be deleted as long as the worksheet is protected.
This behavior, of course, is not terribly useful for any worksheet developer that really wants people to have the ability to delete rows in a worksheet, regardless of whether cells in the rows are locked. If you are one of those people, then the only thing you can do is create a macro that does the deletion for you. The macro must accomplish the following steps:
These three steps are relatively easy to perform, using techniques described in other issues of ExcelTips. To make the macro useful, you will probably want to add code that ensures the user isn't trying to delete rows you don't want them to delete (headings, totals, etc.)
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3004) applies to Microsoft Excel 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Inserting and Deleting Rows in a Protected Worksheet.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
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 MoreOnce you protect a worksheet, you may run into problems with any combo boxes that the worksheet contains. This is a ...
Discover MoreIt is not unusual, in a corporate world, to be handed a worksheet whose source you don't know. If that worksheet is ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2017-11-09 18:28:14
i've locked a column in a worksheet and want the user to be able to insert a row in that worksheet when needed. I've unlocked the entire worksheet, then selected the column that I needed locked. I then protected the worksheet with the stipulation that they can edit unlocked cells and insert a row. It protected the column that I needed, but when I try to insert a row, it wont' let me - it is grayed out. Any advice?
2017-08-11 07:15:34
Rod
Thanks
good tips for deleting
But what about selecting entire rows in a protected sheet and wanting to do <<Insert Copied Cells> so that al teh formulas are included - niot just blank cells.
Normal <<Copy>> and <<Paste>> works fine but only gives blank cells and no foirmulas but <<Insert Copied Cells> doesn't work. :(
I think I might have to write some code but it does seem rather stupid that having enabled Insert Rows in the Protect dialog, that Insert Copied Rows doesn't work!
Anything I am missing??
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments