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
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