LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,073
Default Protect Data validation cells from copy paste

On May 17, 7:51 pm, Guneet Ahuja <Guneet
wrote:
Hi,

I have unlocked some cells with data validation, now after protecting the
work sheet, when the user types in data the validation is working fine.
However it also allows user to copy - paste any value in these cells
irrespective of the vaidaion conditions. Request you to please let me know
how to correct this and make even copy - paste of data subject to data
validation?


You can't validate the pasted data, but you could prevent pasting of
data into the cells with data validation. To do that you use the
worksheet's Selection_Change Event to set the CutCopyMode of Excel
equal to True or False (doesn't matter which) whenever the validated
cells are selected, eg where the validated cell
is A1...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
Application.CutCopyMode = True
End If
End Sub

This method of course fails should the user choose not to allow macros
when the workbook is opened.

To try this out...

Copy the code, Right click the worksheet tab, choose "View code", then
paste it into the code module, then Alt+F11 to return to Excel.

Ken Johnson
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem data validation and copy/paste Theo Excel Worksheet Functions 2 January 13th 08 08:30 PM
Data Validation - Copypaste special problem WCM Excel Discussion (Misc queries) 2 October 24th 06 02:13 AM
Copy/Paste over rides data validation jk Setting up and Configuration of Excel 1 July 23rd 06 03:39 AM
Protect from copy/paste jamex Excel Discussion (Misc queries) 0 March 18th 06 08:21 AM
Data validation does not seem to work with copy/paste LAF Excel Discussion (Misc queries) 1 September 15th 05 09:31 PM


All times are GMT +1. The time now is 08:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"