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.
Written by Allen Wyatt (last updated December 16, 2020)
This tip applies to Excel 2007, 2010, 2013, and 2016
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:
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.
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!
The Data Validation capabilities of Excel can be very helpful when you are trying to control what people can enter into a ...
Discover MoreWant to establish a "bottom limit" on what dates can be entered in a cell? This tip presents two different ways you can ...
Discover MoreWhen using data validation, you might want to have Excel display a message when someone starts to enter information into ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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
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
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>
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.
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