Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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


arrow blue right bubbleDisable 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.


arrow blue right bubbleRelated articles:


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    RN PK · 1 months ago
    Thanks it works perfect ....can it be applied on a range only somehow?
  • To post as a guest, your comment is unpublished.
    Sam · 3 months ago
    It really works well, thanks a lot.
  • To post as a guest, your comment is unpublished.
    Vic · 3 months ago
    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.
  • To post as a guest, your comment is unpublished.
    Al Hammad · 7 months ago
    Thank your for your direction.I am Trying in office 2013 ,but nothing changed.
  • To post as a guest, your comment is unpublished.
    Garak0410 · 9 months ago
    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.
    • To post as a guest, your comment is unpublished.
      crystal · 9 months ago
      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
      • To post as a guest, your comment is unpublished.
        Garak0410 · 9 months ago
        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...