Ir para o conteúdo principal

Como desabilitar as funções cortar, copiar e colar no Excel?

Suponha que você tenha uma pasta de trabalho com dados importantes que você precisa proteger de serem cortados, copiados e colados. Como conseguir isso? Este artigo fornece um método VBA para você desabilitar as funções cortar, copiar e colar ao mesmo tempo em uma pasta de trabalho do Excel.

Desative as funções cortar, copiar e colar com o código VBA


Desative as funções cortar, copiar e colar com o código VBA

Faça o seguinte para desativar as funções cortar, copiar e colar em uma pasta de trabalho do Excel.

1. Na pasta de trabalho, você precisa desativar as funções de cortar, copiar e colar, pressione o outro + F11 simultaneamente para abrir o Microsoft Visual Basic para Aplicações janela.

2. No Microsoft Visual Basic para Aplicações janela, por favor clique duas vezes Esta pasta de trabalho no lado esquerdo Projeto painel e, em seguida, copie e cole o código VBA abaixo no Esta Pasta de Trabalho (Código) janela. Veja a imagem:

Código VBA: desative as funções cortar, copiar e colar ao mesmo tempo no 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. Em seguida, pressione o outro + Q chaves para sair do Microsoft Visual Basic para Aplicações janela.

Agora você não pode cortar ou copiar dados desta pasta de trabalho, enquanto isso, os dados que você copiou de outras planilhas ou pastas de trabalho não podem ser colados nesta pasta de trabalho.

Note: A função arrastar e soltar também é desabilitada após a execução do código VBA acima.


Artigos relacionados:

Melhores ferramentas de produtividade de escritório

🤖 Assistente de IA do Kutools: Revolucionar a análise de dados com base em: Execução Inteligente   |  Gerar Código  |  Crie fórmulas personalizadas  |  Analise dados e gere gráficos  |  Invocar funções do Kutools...
Recursos mais comuns: Encontre, destaque ou identifique duplicatas   |  Excluir linhas em branco   |  Combine colunas ou células sem perder dados   |   Rodada sem Fórmula ...
Super pesquisa: VLookup de múltiplos critérios    VLookup de múltiplos valores  |   VLookup em várias planilhas   |   Pesquisa Difusa ....
Lista suspensa avançada: Crie rapidamente uma lista suspensa   |  Lista suspensa de dependentes   |  Lista suspensa de seleção múltipla ....
Gerenciador de colunas: Adicione um número específico de colunas  |  Mover colunas  |  Alternar status de visibilidade de colunas ocultas  |  Compare intervalos e colunas ...
Recursos em destaque: Foco da Grade   |  Vista de Design   |   Grande Barra de Fórmula    Gerenciador de pastas de trabalho e planilhas   |  Biblioteca (Auto texto)   |  Data Picker   |  Combinar planilhas   |  Criptografar/Descriptografar Células    Enviar e-mails por lista   |  Super Filtro   |   Filtro Especial (filtro negrito/itálico/tachado...) ...
15 principais conjuntos de ferramentas12 Texto Ferramentas (Adicionar texto, Remover Personagens, ...)   |   50+ de cores Tipos (Gráfico de Gantt, ...)   |   Mais de 40 práticos Fórmulas (Calcule a idade com base no aniversário, ...)   |   19 Inclusão Ferramentas (Insira o código QR, Inserir imagem do caminho, ...)   |   12 Conversão Ferramentas (Números para Palavras, Conversão de moedas, ...)   |   7 Unir e dividir Ferramentas (Combinar linhas avançadas, Dividir células, ...)   |   ... e mais

Aprimore suas habilidades de Excel com o Kutools para Excel e experimente uma eficiência como nunca antes. Kutools para Excel oferece mais de 300 recursos avançados para aumentar a produtividade e economizar tempo.  Clique aqui para obter o recurso que você mais precisa...

Descrição


Office Tab traz interface com guias para o Office e torna seu trabalho muito mais fácil

  • Habilite a edição e leitura com guias em Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Abra e crie vários documentos em novas guias da mesma janela, em vez de em novas janelas.
  • Aumenta sua produtividade em 50% e reduz centenas de cliques do mouse para você todos os dias!
Comments (51)
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
Hi,
I tried this vba code for sheet 7 ( for example)
But it does not work on sheet 7 and only work when I copy a cell from the sheet 7 to another sheet so does not allow to paste in another sheet.
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?
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations