Skip to main content

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:

Best Office Productivity Tools

Supercharge Your Spreadsheets: Experience Efficiency Like Never Before with Kutools for Excel

Popular Features: Find/Highlight/Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns     Move Columns   |   Unhide Columns   |   Compare Columns to Select Same & Different Cells ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolset12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   Many More...

Kutools for Excel boasts over 300 features, ensuring that what you need is just a click away...

Supports Office/Excel 2007-2021 & newer, including 365   |   Available in 44 languages   |   Enjoy a full-featured 30-day free trial.

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!
Comments (50)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
è possível realizar apenas em uma linha ou coluna específica?
This comment was minimized by the moderator on the site
Hi RAPHAEL,
If you only want to disable the Cut, Copy and Paste options in a certian column or row, the following VBA codes can help.
1. Open the worksheet (such as Sheet1) where you want to disable these options in a certian column or row, right click the sheet tab and click View Code from the right-clicking menu.
2. Copy the following VBA code to the Worksheet (Code) window.
Note: In the code, "Sheet1!$D:$D" stand for the sheet name and the column. You can change it to the sheet name and column of your own.
If you need to disable a row (such as row 3) in that worksheet, change $D:$D to 3:3.
Worksheet (Code) editor:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
    Dim Rg As Range
    Dim xRg As Range

    Set xRg = Range("Sheet1!$D:$D")
    Set Rg = Intersect(ActiveWindow.RangeSelection, xRg)
    If Rg Is Nothing Then
        Application.OnKey "^c"
    Else
        Application.CutCopyMode = False
        Application.OnKey "^c", ""
        Application.CellDragAndDrop = False
    End If

End Sub

3. Stay in the Visual Editor, double click ThisWorkbook in the left pane, and then copy the following code into the ThisWorkbook (code) window.
4. Press the Alt + Q keys to close the Visual Editor.
ThisWorkbook (Code) editor:

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
On Error Resume Next
    Dim Rg As Range
    Dim xRg As Range

    Set xRg = Range("Sheet1!$D:$D")
    Set Rg = Intersect(ActiveWindow.RangeSelection, xRg)
    If Rg Is Nothing Then
        Application.OnKey "^c"
    Else
        Application.CutCopyMode = False
        Application.OnKey "^c", ""
        Application.CellDragAndDrop = False
    End If


End Sub
This comment was minimized by the moderator on the site
É possível desabilitar a tecla de atalho ctrl+D?
This comment was minimized by the moderator on the site
I added the code but if I want to re-enable it how should I do it, please help immediately.
This comment was minimized by the moderator on the site
Just save it as a file without macros (.xlsx)
This comment was minimized by the moderator on the site
Hi! Is it possible to leave separate cells available for editing/copying/pasting but all the other cells on the same sheet should keep protected from all the actions mentioned before. If yes - how to do that? 
This comment was minimized by the moderator on the site
Is it possible to leave separate cells available for copying/pasting/editing? All the other cells on this sheet should be protected from the mentioned action
This comment was minimized by the moderator on the site
I have multiple sheet in my workbook & i want to use this code for one sheet only....i want to paste in worksheet module not in the workbook........can someone please modify it only for a worksheet
This comment was minimized by the moderator on the site
Hi, Shift to the worksheet where you want to disable the Cut, Copy And Paste Functions, right click the sheet tab and then copy and paste the VBA below into the Sheet (Code) window. Then the Cut, Copy And Paste functions will be disabled only in this sheet.<div data-tag="code">Private Sub Worksheet_Activate()
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub

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

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

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

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

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

Private Sub Worksheet_SheetDeactivate(ByVal Sh As Object)
Application.CutCopyMode = False
End Sub
This comment was minimized by the moderator on the site
thnk u so much....it make my work very easy & also i learned ...thnks
This comment was minimized by the moderator on the site
I have multiple sheet in my workbook & i want to use this code for one sheet only...can someone please modify it only for a worksheet
This comment was minimized by the moderator on the site
hi sir, can you please change it only for worksheet
This comment was minimized by the moderator on the site
Is there a way to allow copy pasting on another workbook? The only thing I don't want is pasting in this workbook. Thank you
This comment was minimized by the moderator on the site
Hi, a question i have a Macro and i feed this file with another file then i need:

1. Allow Copy the external file and copy in my macro
2. Prevent Copy in my macro and paste to external file is posible?
This comment was minimized by the moderator on the site
Hello!I am trying to disable cut/paste tool in MS excel 2016 not the copy/paste tool. Can you give an idea?Thanks in advance!
This comment was minimized by the moderator on the site
Reposting so it is public-apologizing in advance to administrators.
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 copy/paste of acceptable data from drop downs.

Thank you.
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.
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
I used this code & want to Re-enable again? how to re-enable it?
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
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
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
Thank you, very useful.
This comment was minimized by the moderator on the site
THANKS SIR
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
It really works well, thanks a lot.
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
Thank your for your direction.I am Trying in office 2013 ,but nothing changed.
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
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
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
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
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
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
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
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!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations