That is part of what you copy to ThisWorkbook. The example shows Range("A1:A20") of Sheet1 and Range("G1:G20") of Sheet2, but you can modify these as needed. The up side is that this will disable cut, copy and paste for the range you want. Unfortunately, when this line is ran, when you are not in the range that is ok to copy and paste from it deselects whatever you copied and then unable to paste. I removed the following line from the main toggle function. My minor modification I left in, but commented it out. MsgBox "Sorry! Cutting, copying and pasting have been disabled in this workbook!" 'Inform user that the functions have been disabled If Not cBarCtrl Is Nothing Then cBarCtrl.Enabled = Enabled Set cBarCtrl = cBar.FindControl(ID:=ctlId, recursive:=True)
Sub EnableMenuItem(ctlId As Integer, Enabled As Boolean) 'Activate/deactivate cut, copy, paste and pastespecial shortcut keys 'Activate/deactivate drag and drop ability 'Activate/deactivate cut, copy, paste and pastespecial menu itemsĬall EnableMenuItem(755, Allow) ' pastespecial Sub ToggleCutCopyAndPaste(Allow As Boolean)
HOW TO LOCK CERTAIN CELLS IN EXCEL 2013 CODE
Put the following code in a standard module: 'Re-enable cut copy and paste commands as this is not a restricted sheet If Not Intersect(Target, ("G1:G20")) Is Nothing Then 'Disable cut, copy & paste for Sheet2, Range A1:A20
If Not Intersect(Target, ("A1:A20")) Is Nothing Then
'Disable cut, copy & paste for Sheet1, Column A 'Toggle the cut, copy & paste commands on selected ranges Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) 'Re-enable the cut, copy & paste commands Private Sub Workbook_BeforeClose(Cancel As Boolean) 'Force the current selection to be selected, triggering the appropriate