FREE Excel STUFF
SearchSearch Excel Content
PRODUCTS
Development
Contact
Excel Online

Excel VBA: Disable Cut/Copy in Excel Workbooks

Complete Excel Excel Training Course. Instant Buy/Download, 30 Day Money Back Guarantee

Current Special! Complete Excel Excel Training Course for Excel 97 - Excel 2003, only $145.00. $59.95 Instant Buy/Download, 30 Day Money Back Guarantee & Free Excel Help for LIFE!

Back to: Excel VBA . Got any Excel/VBA Questions? Free Excel Help

While we can stop users cutting/copying cells via Worksheet and/or Workbook protection, this is often at the expense of losing other Excel features that you may still want Excel users to access. The code below can be used to stop users being able to Cut or Copy any cells in the Workbook. However, you must realise that it will only work if the user elects to Enable Macros. No, one cannot force the enabling of macros via VBA

The code below must be placed in the Private Module of the Workbook Object (ThisWorkbook). To get there easily, right click on the Excel icon, top left next to File and choose View Code. In here paste the code below, close & save and then re-open.

Private Sub Workbook_Activate()

Dim oCtrl As Office.CommandBarControl

 

'Disable all Cut menus

     For Each oCtrl In Application.CommandBars.FindControls(ID:=21)

            oCtrl.Enabled = False

     Next oCtrl

    

'Disable all Copy menus

     For Each oCtrl In Application.CommandBars.FindControls(ID:=19)

            oCtrl.Enabled = False

     Next oCtrl

       

        Application.CellDragAndDrop = False



End Sub



Private Sub Workbook_Deactivate()

Dim oCtrl As Office.CommandBarControl

 

'Enable all Cut menus

     For Each oCtrl In Application.CommandBars.FindControls(ID:=21)

            oCtrl.Enabled = True

     Next oCtrl

    

'Enable all Copy menus

     For Each oCtrl In Application.CommandBars.FindControls(ID:=19)

            oCtrl.Enabled = True

     Next oCtrl

       

        Application.CellDragAndDrop = True



End Sub



Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

    With Application

        .CellDragAndDrop = False

        .CutCopyMode = False 'Clear clipboard

    End With

End Sub

List of Excel 2000 CommandBar Button IDs applies to excel 97 onwards.

Excel Dashboard Reports & Excel Dashboard Charts 50% Off

Special! Free Choice of Complete Excel Training Course OR Excel Add-ins Collection on all purchases totaling over $64.00. ALL purchases totaling over $150.00 gets you BOTH! Purchases MUST be made via this site. Send payment proof to special@ozgrid.com 31 days after purchase date.



Instant Download and Money Back Guarantee on Most Software

Excel Trader Package Technical Analysis in Excel With $139.00 of FREE software!

Add to Google Search Tips FREE Excel Help

Microsoft ® and Microsoft Excel ® are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft