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: Stopping Validated Data from being Overwritten.

Stopping Validated Data from being Overwritten

by Allen Wyatt
(last updated February 18, 2017)

7

Melissa uses Data Validation regularly to limit what can be put into a cell. She notes that one flaw seems to be that it's always possible to overwrite the data by copying a cell from somewhere else in the file and pasting it into the cell that should be limited by Data Validation. Melissa wonders if there is any way to "lock down" the cells that have Data Validation, so no one can paste over them.

Melissa has discovered what some have called the "Achilles' heel" of Data Validation—you can paste over cell contents and thereby destroy whatever Data Validation rules were in the target cells. The only possible way around this is to use a macro to head off pasting into certain areas of the worksheet. A good way to do that is found at John Walkenbach's site:

http://spreadsheetpage.com/index.php/tip/ensuring_that_data_validation_is_not_deleted/

There are some limitations to the macros noted on that page, but there are some drawbacks that are not noted:

  • If a person doesn't enable macros when the workbook is opened, then the macro code can't do its job. (This is, honestly, a drawback to any macros for any purpose.)
  • The worksheet may seem a bit sluggish if the range of cells being protected is large, as the macro runs every time a change is made in the worksheet.
  • Because the macro runs every time the worksheet is changed, it effectively removes any possibility of having an "undo" feature in the worksheet. (Macros, when run, cannot be undone and clear the undo stack.)

Even with the drawbacks and limitations, this approach is probably the best way to overcome the potential problem.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11799) 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: Stopping Validated Data from being Overwritten.

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

Unwanted Cover Pages with Print Jobs

When you print a document, do you get more than you bargained for? If you get extra pages printed either before or within ...

Discover More

Printing Selected Worksheets

When you accumulate quite a few workbooks in folder, you might need to print out selected worksheets from all of the ...

Discover More

Pasting a Hyperlink

Need a quick link within a document to some external data? You can paste information so that Excel treats it just like a ...

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)

Contingent Validation Lists

Data validation can be used to create lists of choices for entry into a particular cell. Using the techniques in this tip you ...

Discover More

Answering Questions in Order

It is not unusual to use Excel to gather the answers to users' questions. If you want your users to answer your questions in ...

Discover More

Ensuring Unique Values in a Column

If you want to make sure that only unique values are entered in a particular column, you can use the data validation ...

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 8Mpixels. 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 7 - 0?

2017-02-19 14:26:07

Alec Whatmough

I do the same as riaz, but make the sheets Very Hidden to prevent users from opening it with macros disabled and simply unhiding sheets (no, I don't understand why they do it either..)


2016-08-26 05:17:49

riaz

To force the user to allow macros to run, I hid all the tabs except one which I call "Welcome", which just has a message that the workbook needs macros enabled to run.

Once macros are enabled, the "Welcome" tab is hidden and all the other tabs are revealed. On closing, all the tabs are hidden and "Welcome" is unhidden again.

Thus, at each opening, macro enabling is forced, or the workbook remains inaccessible.


2016-02-23 09:58:51

KevinL

this seems too work for copying from inside and outside the workbook - without using macros.

put in validation using a list in the normal way. (keep the cells locked) Assume this is in the range E5:E11

merge each cell with the one beside it (i.e. merge E5 with F5 etc) for the whole range (keep these cells locked as well).

then go to the review tab::changes::allow users to edit range

select the left most range only - e.g. E5:E11,
protect the sheet in the normal way and it should work - any comments?


2015-11-03 18:47:22

game writer guy

I just posted about how to fix the overwrite problem without VBA over at http://superuser.com/questions/617589/how-to-protect-data-validation-to-fail-while-copy-and-paste-data/995693#995693

My question is related: now that we can smoothly preserve the validation, how do you get Excel to perform validation on pasted data instead of sitting on its hands?


2015-06-18 07:03:26

balthamossa2b

Way easier solution, supposing the validated data is a list: insert a dropdown list Object, available in the Developper tab.

Then tie its value to a cell hidden somewhere, and tadah! You can use the listed value in a cell formula.

No need to use Event macros when it can be avoided.



In case it's a boolean, use a Checkbox.


2014-05-30 06:28:20

Tony King

This function works perfectly for data that is copied from the active workbook. However it does not work when data is copied and pasted from another workbook.
Can this be added?
Thanks
Tony


2012-12-21 10:44:51

Kevin

The recommended code just loops and returns the error message an unending number of times when just one cell has a copy/paste entered that overwrites/invalidates the Data Validation rule. The only way to stop the endless errors is <Ctrl> <Break>


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.