Note: The other languages of the website are Google-translated. Back to English

How to disable cut, copy and paste functions in Excel?

Supposing you have a workbook with important data which you need to protect from being cut, copied and pasted. How to achieve it? This article provides a VBA method for you to disable the cut, copy and paste functions at the same time in an Excel workbook.

Disable cut, copy and paste functions with VBA code


Disable cut, copy and paste functions with VBA code

Please do as follows to disable the cut, copy and paste functions in an Excel workbook.

1. In the workbook you need to disable the cut, copy and paste functions, please press the Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, please double click ThisWorkbook in the left Project pane, and then copy and paste the below VBA code into the ThisWorkbook (Code) window. See screenshot:

VBA code: Disable the cut, copy and paste functions at the same time in Excel

Private Sub Workbook_Activate()
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub

Private Sub Workbook_Deactivate()
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.CutCopyMode = False
End Sub

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.CutCopyMode = False
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Application.CutCopyMode = False
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
Application.CutCopyMode = False
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Application.CutCopyMode = False
End Sub

3. Then please press the Alt + Q keys to exit the Microsoft Visual Basic for Applications window.

Now you can’t cut or copy data from this workbook, meanwhile, data you have copied from other sheets or workbooks cannot be pasted into this workbook.

Note: The drag and drop function is also disabled after running the above VBA code.


Related articles:


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (48)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
i do as above but the function of cut copy and past disabled in any excel file i open .why?
This comment was minimized by the moderator on the site
Hi, I used this to hide "Cut" from users and it works great unless you have a Table, the "Cut" miraculously re-appears when you select a cell in the Table, exactly what i'm trying to avoid. any ideas? thanks!
This comment was minimized by the moderator on the site
Thanks u Sir its working .But in Entire workbook. If i need this Code only i particular sheet.Is it Possible ??
This comment was minimized by the moderator on the site
have you found an answer?
This comment was minimized by the moderator on the site
Thanks a Lot.Its working in entire worbook. Can we do the coding only for 1 sheet.Please help .
This comment was minimized by the moderator on the site
How to enable the cut, copy and paste function back? Please advice!
This comment was minimized by the moderator on the site
Dear Sky
Please run the below VBA1 (place the code in the ThisWorkbook module) to disable the cut, copy and paste function in your workbook.

VBA1:
Sub DelCopy()
With Application
.OnKey "^x", ""
.OnKey "^c", ""
.CommandBars("Cell").Controls(1).Enabled = False
.CommandBars("Cell").Controls(2).Enabled = False
End With
End Sub

And the run the VBA2 to enable all these functions back to your workbook.

VBA2:
Sub RecoverCopy()
With Application
.OnKey "^x"
.OnKey "^c"
.CommandBars("Cell").Controls(1).Enabled = True
.CommandBars("Cell").Controls(2).Enabled = True
End With
End Sub
This comment was minimized by the moderator on the site
This doesn't seem to have worked for me - should I delete the original VBA code and then paste the above in to enable the Cut, copy and paste function again?
This comment was minimized by the moderator on the site
Good Day,
The VBA1in above comment is the replacement of the original code.
This comment was minimized by the moderator on the site
Dear,

i want to disable cut, copy, paste in excel 2007 sheet
can you share code for this
This comment was minimized by the moderator on the site
Good Day,
Thank you for your comment. I am trying to figure out the solution for Excel 2007. Please wait patiently.
This comment was minimized by the moderator on the site
Hi,
Is it possible to disable "CUT" only? but I could still use the Copy and Paste?
This comment was minimized by the moderator on the site
Hi Carmelo,
Please copy and paste the below code into the Workbook code window in your workbook and then save it as an Excel Macro-enabled workbook. Then the "Cut" function will be disabled.

Option Explicit
Private WithEvents Cmbrs As CommandBars

Private Sub Workbook_Open()
Set Cmbrs = Application.CommandBars
End Sub

Private Sub Workbook_Activate()
If Application.CutCopyMode = 2 Then
Application.CutCopyMode = 0
End If
End Sub

Private Sub Cmbrs_OnUpdate()
If Me Is ActiveWorkbook Then
If Application.CutCopyMode = 2 Then
Application.CutCopyMode = 0
MsgBox "Cut Operations disabled"
End If
End If
End Sub
This comment was minimized by the moderator on the site
I tried just like you said but nothing happends. A want exactly the same, Only the
"Cut" function disabled. I need to disable the "cut" option from Rightclick buton option and from the toolbar.
It is posible crystal??
This comment was minimized by the moderator on the site
Good day,
The code works well in my case. May I know your Office version?
This comment was minimized by the moderator on the site
Hi

I´m a beginner of VBA codes and this code solved 99% of my problems.

Is it possible to lock the hole sheet (as this code dose) but still have one cell unlocked?
(Clarify, I would like to allow copy past in info in only one cell in the hole sheet).

Best regards
L
This comment was minimized by the moderator on the site
Hello Linda,
You can solve the problem without using VBA code.
Right click the cell and select Format Cells from the context menu, uncheck the Locked box under the Protection tab in the dialog. And then protect the worksheet with password.
This comment was minimized by the moderator on the site
Was super glad to find this post but I need a little help in limiting this to a single worksheet in a multi-worksheet Workbook. And need to know how to execute this without user intervention...we need this ASAP on a workbook to help prevent errors.
This comment was minimized by the moderator on the site
Good day,
The following VBA code can help you to solve the problem. And don't forget to replace "Sheet2" in the code with your sheet name.

Public mJWSName As String

Private Sub Workbook_Open()
mJWSName = "Sheet2"
End Sub

Private Sub Workbook_Activate()
If ActiveSheet.Name = mJWSName Then
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End If
End Sub

Private Sub Workbook_Deactivate()
Application.OnKey "^c", ""
Application.CellDragAndDrop = True
Application.CutCopyMode = False
End Sub


Private Sub Workbook_WindowActivate(ByVal Wn As Window)
If ActiveSheet.Name = mJWSName Then
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End If
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.OnKey "^c"
Application.CellDragAndDrop = True
Application.CutCopyMode = False
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next
If Sh.Name = mJWSName Then
Application.CutCopyMode = False
End If
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
On Error Resume Next
If Sh.Name = mJWSName Then
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
Application.CutCopyMode = False
End If
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Application.OnKey "^c"
Application.CellDragAndDrop = True
Application.CutCopyMode = False
End Sub
This comment was minimized by the moderator on the site
One last question - Where does this code go and how does it get executed? The project this needs to work with attaches an XLA file to the Excel sheet that contains much of the code. Didn't know if this needs to go into a module or the code behind this sheet. Thanks...
This comment was minimized by the moderator on the site
Thank your for your direction.I am Trying in office 2013 ,but nothing changed.
This comment was minimized by the moderator on the site
Hi, the code works well thanks.
However, the read only option was enabled. (if you don't want to modify). If I set ..File, save as, tools, general options, read only recommended.. then the code does not work.

Thanks in advance.
This comment was minimized by the moderator on the site
It really works well, thanks a lot.
This comment was minimized by the moderator on the site
Thanks it works perfect ....can it be applied on a range only somehow?
This comment was minimized by the moderator on the site
Good day,
Sorry can't help you with that. Welcome to post any question in our forum: https://www.extendoffice.com/forum.html. Thank you for your comment.
This comment was minimized by the moderator on the site
THANKS SIR
This comment was minimized by the moderator on the site
Thank you, very useful.
This comment was minimized by the moderator on the site
cut copy paste applicable Entire workbook. If i need this Code only i particular sheet.Is it Possible ??
please help. we need only one sheet disable functions. another sheet we are working all functions...
This comment was minimized by the moderator on the site
That code isn't working in my excel 2016 for a single sheet instead of the whole workbook
This comment was minimized by the moderator on the site
This still allows pasting from Notepad or Microsoft Edge. Please see if there is a way prevent pasting from any source.
This comment was minimized by the moderator on the site
Hi,
If prevent pasting from any source, we need to prevent the Notepad feature, which may bring inconvenience. We do not recommend this. Sorry can't help you for that.
This comment was minimized by the moderator on the site
I used this code & want to Re-enable again? how to re-enable it?
This comment was minimized by the moderator on the site
use this code to disable copy cut & paste



Private Sub Workbook_Activate()

Application.CutCopyMode = False

Application.OnKey "^c", ""

Application.CellDragAndDrop = False

End Sub



Private Sub Workbook_Deactivate()

Application.CellDragAndDrop = True

Application.OnKey "^c"

Application.CutCopyMode = False

End Sub



Private Sub Workbook_WindowActivate(ByVal Wn As Window)

Application.CutCopyMode = False

Application.OnKey "^c", ""

Application.CellDragAndDrop = False

End Sub



Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)

Application.CellDragAndDrop = True

Application.OnKey "^c"

Application.CutCopyMode = False

End Sub



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

Application.CutCopyMode = False

End Sub



Private Sub Workbook_SheetActivate(ByVal Sh As Object)

Application.OnKey "^c", ""

Application.CellDragAndDrop = False

Application.CutCopyMode = False

End Sub



Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)

Application.CutCopyMode = False

End Sub





and want to enable these function again
This comment was minimized by the moderator on the site
This works great, how would one modify this to allow copy/paste in specific columns that have pull down menus tied to named ranges of acceptable input and only the acceptable input. For instance a name that is Jetson, George, 25, would allow a copy/paste of Jetson, George, 25 but would not allow Jeston, George, 26. Or a drag and fill that would result in Jetson, George, 25 then 26, then 27, etc.
In my worksheet I want to completely disable cut/copy/paste in certain columns, then only allow cut copy paste of acceptable data from drop downs.
Thank you.
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
×
Rate this post:
0  Characters
Suggested Locations