• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA to protect copy/paste in excel for cells having data validation

amrit1186

Member
Hi


I am new to macros. I have written the following code to prevent anyone from copy/pasting the values to validated cell which is activated whenever the selection changes in the worksheet.


Sub DisablePaste()

Dim X As Variant

On Error Resume Next

X = ActiveCell.Validation.Type

If Not IsEmpty(X) Then

Application.CutCopyMode = False

Application.CellDragAndDrop = False

End If

End Sub


The code works fine if somebody tries to copy/paste within the excel sheet. But it fails if the text is copied from some other file. HOw to prevent this failure.


Thanks for your help.


Amritansh
 
Hi Amritansh ,


Have you gone through these links ?


1. http://www.mrexcel.com/forum/excel-questions/419867-disable-copy-paste-range-cells-data-validation.html


2. http://www.excelbanter.com/showthread.php?t=15638


Narayan
 
Back
Top