Disable "Cut" only

  • Thread starter Thread starter sparx
  • Start date Start date
S

sparx

Can anybody help, I have been looking for some VBA code that will
disable just the CUT feature of excel - allowing all other functions
like COPY & PASTE still to work as normal. Several codes I have found
disables the CUT, and also disables the COPY & PASTE from working as
well. Does anybody know of some VBA that will also stop only the CUT
used either from the keyboard CTRL+X, or from menu's in the toolbar.
Thanks
 
Thanks for your direction - I have tried those sites and they provid
VBA that stops all the copy, cut, paste etc working, I only want t
stop the CUT from working by either keyboard shortcut or menu options
I did though find this code and altered it and it did sort of work bu
not properly - so can anybody help with the following -

-- Worksheet_Activate Event --

Sub DisableCutCopy()
On Error Resume Next
With Application
'disables shortcut keys
.OnKey "^c", ""
.OnKey "^v", ""
.OnKey "^x", ""
'Disables Copy
.CommandBars("Edit").FindControl(Id:=19).Enabled = False
.CommandBars("Edit").FindControl(Id:=848).Enabled = False
.CommandBars("Cell").FindControl(Id:=19).Enabled = False
.CommandBars("Column").FindControl(Id:=19).Enabled = False
.CommandBars("Row").FindControl(Id:=19).Enabled = False
.CommandBars("Button").FindControl(Id:=19).Enabled = False
.CommandBars("Formula Bar").FindControl(Id:=19).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(Id:=19).Enabled
False
.CommandBars("Standard").FindControl(Id:=19).Enabled = False
.CommandBars("Button").FindControl(Id:=848).Enabled = False
.CommandBars("Formula Bar").FindControl(Id:=848).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(Id:=848).Enabled
False
.CommandBars("Standard").FindControl(Id:=848).Enabled = False
.CommandBars("Ply").FindControl(Id:=848).Enabled = False
'Disables Cut
.CommandBars("Edit").FindControl(Id:=21).Enabled = False
.CommandBars("Cell").FindControl(Id:=21).Enabled = False
.CommandBars("Column").FindControl(Id:=21).Enabled = False
.CommandBars("Row").FindControl(Id:=21).Enabled = False
.CommandBars("Button").FindControl(Id:=21).Enabled = False
.CommandBars("Formula Bar").FindControl(Id:=21).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(Id:=21).Enabled
False
.CommandBars("Standard").FindControl(Id:=21).Enabled = False
End With
End Sub

-- Worksheet_Deactivate Event --

Sub EnableCutCopy()
On Error Resume Next
With Application
.OnKey "^c"
.OnKey "^v"
.OnKey "^x"
'Enables Copy
.CommandBars("Edit").FindControl(Id:=19).Enabled = True
.CommandBars("Edit").FindControl(Id:=848).Enabled = True
.CommandBars("Cell").FindControl(Id:=19).Enabled = True
.CommandBars("Column").FindControl(Id:=19).Enabled = True
.CommandBars("Row").FindControl(Id:=19).Enabled = True
.CommandBars("Button").FindControl(Id:=19).Enabled = True
.CommandBars("Formula Bar").FindControl(Id:=19).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(Id:=19).Enabled
True
.CommandBars("Standard").FindControl(Id:=19).Enabled = True
.CommandBars("Button").FindControl(Id:=848).Enabled = True
.CommandBars("Formula Bar").FindControl(Id:=848).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(Id:=848).Enabled
True
.CommandBars("Standard").FindControl(Id:=848).Enabled = True
.CommandBars("Ply").FindControl(Id:=848).Enabled = True
' Enables Cut
.CommandBars("Edit").FindControl(Id:=21).Enabled = True
.CommandBars("Cell").FindControl(Id:=21).Enabled = True
.CommandBars("Column").FindControl(Id:=21).Enabled = True
.CommandBars("Row").FindControl(Id:=21).Enabled = True
.CommandBars("Button").FindControl(Id:=21).Enabled = True
.CommandBars("Formula Bar").FindControl(Id:=21).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(Id:=21).Enabled
True
.CommandBars("Standard").FindControl(Id:=21).Enabled = True
End With
End Sub

I removed all the code that didnt relate to the CUT option ( I believ
is 21 ) and put this into the "ThisWorkbook" of an Excel file - but fo
some reason it still let me cut - where am I going wrong
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top