Prevent Only CUT and PASTE from the user Not COPY

kukerjoe

New Member
Joined
Jan 1, 2018
Messages
7
Hi,
i want to prevent the user from doing Cut and Paste but to allow him to preform Copy and paste ( when they are doing Cut and Paste their getting Ref# error in formulas)
when i use this code it prevents also the Copy and Paste which is needed by user and it doesn't do the Ref error

Code:
application.CutCopyMode=False

Thanks!
 
Last edited by a moderator:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hello,

I have this in one of my spreadsheets and it works quite nicely, this is set on my sheet and tells the user not to use cut and paste (no idea where this code came from as I forgot to put a link in)

Code:
Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Select Case Application.CutCopyMode
    Case Is = False
'do nothing
    Case Is = xlCopy
'do nothing
    Case Is = xlCut
    MsgBox "Please DO NOT Cut and Paste!"
    Application.CutCopyMode = False 'clear clipboard and cancel cut
End Select

End Sub

You can also stop the user pressing Ctrl X via this little bit of code, it reactivates when they come off this sheet
Code:
Private Sub Worksheet_Activate()
Application.OnKey "^x", ""
End Sub

Private Sub Worksheet_Deactivate()
Application.OnKey "^x"
End Sub

then there is this code which will remove the cut option from the menu (right click cut will be greyed out) - this code is from ozgrid (remembered the link when I found this one!!). The message above will also capture this one, however I think its nice to show the user they don't have the option as well!

Code:
Sub testme()
'Disable all Cut menus

For Each oCtrl In Application.CommandBars.FindControls(ID:=21)
oCtrl.Enabled = False
Next oCtrl
'Disable all Copy menus

End Sub

to active the menu again:
Code:
Sub active()

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

Application.CellDragAndDrop = True

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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