Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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: Stopping the Deletion of Cells.

Stopping the Deletion of Cells

by Allen Wyatt
(last updated August 16, 2014)

4

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 (10256) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel 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

Previewing Your Web Page

Need to see what your document would look like as a Web page? Word allows you to get a glimpse by using the Web Page Preview ...

Discover More

Updating Fields in Locked Forms

Updating form fields in Word can be confusing, especially when the fields are locked in a form. This tips explains why the ...

Discover More

Using Data Validation

Want to control what users put into a cell? It's easy to do using a feature called data validation, as described in this tip.

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Conditionally Deleting Rows

Want to delete a bunch of rows in a worksheet based on the value in a certain cell of each row? There are a couple of ways ...

Discover More

Recording a Data Entry Time

When entering information in a worksheet, it is common to also note a date or time corresponding to the entry. There are ...

Discover More

Copying to Very Large Ranges

Using the mouse to select a large cell range can be frustratingly slow. If you want to make copying to a large range of cells ...

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 6 - 0?

2016-09-23 21:13:11

Bob Quinn

I have Excel 2013. I have a spreadsheet with a list of foods and the carbohydrates and fiber amounts listed. I do a daily count of that data. I am having a problem where data is shifted up or down a row. I frequently scroll back and forth and up and down the spreadsheet. This movement of data corrupts the data so I have to reenter all the data. I know I'm am the cause of this data shift but have no idea what I am doing that causes the data shift. Can you help? Thanks

Bob


2016-09-22 17:01:48

Teresa

I have Excel 2013 and applied this tip to prevent deletion of cells/columns/rows in a worksheet that otherwise needs to be edited by multiple users.
the problem they've all ready discovered is, while the filter feature works, the sort feature is now disabled.
Is there another trick?
or a way to prevent cell/row/column deletion without protecting the sheet?
Thanks


2016-07-28 10:56:51

valeria

It looks like a very good solution for my problem, but unfortunately it did not let me to delete cell, where ="" is and formula above this still not protected. I try to delete it and it let me do it.

thank you very much for any help.

valeria


2016-06-27 09:50:35

George

Excellent! Thanks!


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.