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: Stopping the Deletion of Cells.

Stopping the Deletion of Cells

Written by Allen Wyatt (last updated May 27, 2023)
This tip applies to Excel 97, 2000, 2002, and 2003


Vilas knows that he can protect a worksheet so that users cannot delete cells. However, he has a need to prevent the deletion of cells without using worksheet protection. (Vilas is not talking about the clearing of cell contents, but the actual deletion of cells so that surrounding cells must move left or move up.) He wonders if there is a way to prevent a user from deleting cells, without protecting the worksheet.

There is no direct way to do this in Excel. It would be nice if Excel provided a way to create an event handler that was called whenever a cell was deleted, but it does not. (The Worksheet_Change event is apparently triggered whenever the contents of a cell are changed, but not when a cell is entirely deleted.) Because of this, using a macro to protect your cells from being deleted is not the way to go.

The best solution we've been able to find involves taking advantage of a quirk in how Excel handles array formulas. For the sake of example, let's assume that you have data in the range A1:L37, and you don't want any cells within this range to be deleted. Follow these general steps:

  1. Select the range of cells just to the right of your block you want to protect. In this case, select cells M1:M37.
  2. Type ="" and press Shift+Ctrl+Enter. You've now created a do-nothing array formula that takes the entire range of M1:M37.
  3. Select the range of cells just beneath the block of cells you want to protect. In this case, select cells A38:L38.
  4. Type ="" and press Shift+Ctrl+Enter. You've now created a do-nothing array formula that takes the entire range of A38:L38.

At this point you cannot delete any cell within the data block (A1:L37), nor can you delete any row 1 through 37 or any column A through L. Whenever you try, Excel displays a message that says "You cannot change part of an array." The only way to delete cells, rows, or columns within the data block is to first get rid of the array formulas that would be affected. In other words, you would need to delete column M or row 38 first.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10255) 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: Stopping the Deletion of Cells.

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

Margins for All Documents Changing

Have you had the margins in a group of documents change without you knowingly doing anything? This tip explores some ...

Discover More

Printing a Document's Mirror Image

If you need to print the mirror image (backwards) of a document, you may think you are out of luck in Word. There are ...

Discover More

Understanding Templates

Templates are used to store a pattern for how a document should look. As such, they can be a very powerful tool for ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (menu)

Clearing and Deleting Cells

When you want to remove information from a worksheet, you can either clear cells or delete cells. This tip examines the ...

Discover More

Quickly Deleting Rows and Columns

Deleting rows or columns is easy when you use the shortcut described in this tip. Just select the rows or columns and ...

Discover More

Checking for Duplicate Rows Based on a Range of Columns

When working with data in Excel, you might want to figure out which rows of data represent duplicates of other rows. If ...

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 1 + 1?

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.