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

Written by Allen Wyatt (last updated December 16, 2020)
This tip applies to Excel 2007, 2010, 2013, and 2016


10

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

Setting Decimal Tabs in a Table Using the Keyboard

Most people use the mouse to set tab stops in the paragraphs in a table. If you prefer to not use the mouse, then you'll ...

Discover More

Tab Key Won't Move from Cell to Cell in Locked Worksheet

Normally the Tab key can be used to move from one cell to another in Excel. If this cell movement doesn't work for you, ...

Discover More

Strange ATAN Results

You may use Excel's trigonometric functions to do some quick calculations, and suddenly notice that the results in your ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Adding Pop-Up Documentation to a Cell

Want to have a small help screen pop up when a user selects a particular cell? This can be done by using data validation, ...

Discover More

Creating Dependent Drop-Lists

Drop-down lists are handy in an Excel worksheet, and you they can be even more handy if a selection in one drop-down ...

Discover More

Handling Validation for Proper Latitude

When setting up Excel for data entry, you often have to be concerned with what values are acceptable. For example, 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 seven minus 7?

2019-05-09 06:08:48

esiorfud

Hi everybody,

What could I do to prevent the copy-paste issue not only in one column, but in two or three, with a different kind of validation each one?

Is it possible? Thanks a lot for your help!!!


2019-02-09 11:21:41

Peter Atherton

Karen

The colon is the usual separator for time. You cn change the cell to Text before entry to retain your format. on the other had, if you are calculating the ratio of a pair of numbers use the GCD function this returns the Greatest Common Divisor also knon as the Lowest Common Multiple. and then combine the answer as text:


(see Figure 1 below)



Figure 1. 


2019-02-09 00:29:29

Karen

I have pasted ratios, eg. 1:2, 1:5 in a drop down box, but when l click one of the ratios (1:2) it enters as 1:02 and changes to a time.


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.