This might suffice as well; all the code in the workbook codemodule.
Private Sub Workbook_Activate() ChkSelection ActiveSheet Application.CellDragAndDrop = True End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) ToggleCutCopyAndPaste True Application.CellDragAndDrop = True End Sub Private Sub Workbook_Deactivate() ToggleCutCopyAndPaste True Application.CellDragAndDrop = True End Sub Private Sub Workbook_Open() ChkSelection ActiveSheet Application.CellDragAndDrop = False End Sub Private Sub Workbook_SheetActivate(ByVal Sh As Object) ChkSelection Sh End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) ChkSelection Sh End Sub Sub ChkSelection(ByVal Sh As Object) Select Case Sh.Name Case "Sheet1" ToggleCutCopyAndPaste Intersect(Selection, sh.Columns(1)) Is Nothing Case "Sheet2" ToggleCutCopyAndPaste Not Intersect(Selection, sh.range("G1:G20")) Is Nothing Case Else ToggleCutCopyAndPaste True End Select End Sub Sub ToggleCutCopyAndPaste(v_true As Boolean) EnableMenuItem Array(19, 21, 22, 75), v_true For j = 1 To 5 If v_true Then Application.OnKey Choose(j,"^c", "^v", "^x", "+{DEL}", "^{INSERT}") If Not v_true Then Application.OnKey Choose(j,"^c", "^v", "^x", "+{DEL}", "^{INSERT}"), "CutCopyPasteDisabled" Next End Sub Sub EnableMenuItem(ctlId, v_Enabled As Boolean) On Error Resume Next For Each cb In Application.CommandBars If cb.Name <> "Clipboard" Then For Each it In ctlId cb.FindControl(, it).Enabled = v_Enabled Next End If Next End Sub Sub CutCopyPasteDisabled() MsgBox "Sorry! Cutting, copying and pasting have been disabled for the specified range." End Sub




Reply With Quote