Disable 'Cut' function from worksheet only

mizogy

New Member
Joined
Jul 5, 2011
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hi All

I am trying to find a solution to stop users from cutting and pasting values on a particular worksheet. This to avoid (hidden and protected) formula on the same worksheet from becoming corrupted. I still, however, want to provide the user the ability to copy and paste values.

I used the following code, however it removes the ability to copy and paste values from one cell to another.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.CutCopyMode = False
End Sub

Simply, I want to avoid the ability to cut. Nor, do I want to use code which disables the cut function from their menu for all workbooks / worksheets.

Any ideas - thank you for your help in advance?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Very easy, btw, you don't need any macro for this.. Select and right click to cells you want to protect. Choose Format Cell from context menu. Go to Protection tab. Check both Locked and Hİdden options.

On the contrary, remove these checks from all other cells where you want the values to be copied and pasted.

Finally, right click to sheetname. Choose Protect Sheet. A menu will appear with several options. Leave first two options as checked and set your password.

Ta taa...
 
Upvote 0
Very easy, btw, you don't need any macro for this.. Select and right click to cells you want to protect. Choose Format Cell from context menu. Go to Protection tab. Check both Locked and Hİdden options.

On the contrary, remove these checks from all other cells where you want the values to be copied and pasted.

Finally, right click to sheetname. Choose Protect Sheet. A menu will appear with several options. Leave first two options as checked and set your password.

Ta taa...
Thanks for your response. The issue is not protecting the cells. I want the user to be able to change the value in the cell, either through input or copying values from other cells, for that reason the cell is unlocked. However, I want to avoid the unlocked cell's value being cut and pasted to a corresponding cell. The reason being, formula linking to cell (that formula being hidden and protected) then becomes corrupted by the cell value being cut and pasted to a cell above or below. Best, Mizogy.
 
Upvote 0
Unfortunately, there is no global solution. Word "Kes" means "Cut" in my language. You have to modify it according to language of the excel being used.

VBA Code:
Private Sub Workbook_Open()
 Call DisableCut
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
 Call EnableCut
End Sub

Sub DisableCut()
 With Application
  .CommandBars("Cell").Enabled = False
  .CommandBars("Standard").Controls.Item("Kes").Enabled = False
  .CommandBars("Edit").Controls.Item("Kes").Enabled = False
  .OnKey "^x", "CutDisabled"
  .OnKey ("{Delete}"), "CutDisabled"
  .CellDragAndDrop = False
 End With
End Sub


Sub EnableCut()
 With Application
  .CommandBars("Edit").Controls.Item("Cut").Enabled = True
  .CommandBars("Standard").Controls.Item("Cut").Enabled = True
  .CommandBars("Cell").Enabled = True
  .OnKey "^x"
  .OnKey "{Delete}"
  .CellDragAndDrop = True
 End With
End Sub

Sub CutDisabled()
 Application.CutCopyMode = False
 MsgBox ("Cut Disabled")
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top