SensualCarrots
New Member
- Joined
- Mar 21, 2015
- Messages
- 46
I am using the following code I found somewhere in a workbook to prevent traditional pasting to avoid wiping out cell formatting. I only want to allow paste values.
The problem is that for some reason, once copied, values will be pasted into any cell on the worksheet, regardless if they are locked or not. And yes, the worksheet is protected, but it's protected via the below code which I suspect may be the problem... I commented the entire code block, and it prevents all pasting, including values. Any ideas?
Code:
Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal Target As Range)
If Sheet3.UnlockWorkbookCheckbox = False Then
On Error Resume Next
Target.PasteSpecial xlPasteValues
Application.CutCopyMode = True
End If
End Sub
The problem is that for some reason, once copied, values will be pasted into any cell on the worksheet, regardless if they are locked or not. And yes, the worksheet is protected, but it's protected via the below code which I suspect may be the problem... I commented the entire code block, and it prevents all pasting, including values. Any ideas?
Code:
Sheet3.Protect Password:="password", UserInterfaceOnly:=True