Skip i'r prif gynnwys

Sut i analluogi swyddogaethau torri, copïo a gludo yn Excel?

Gan dybio bod gennych lyfr gwaith gyda data pwysig y mae angen i chi ei amddiffyn rhag cael ei dorri, ei gopïo a'i gludo. Sut i'w gyflawni? Mae'r erthygl hon yn darparu dull VBA i chi analluogi'r swyddogaethau torri, copïo a gludo ar yr un pryd mewn llyfr gwaith Excel.

Analluoga swyddogaethau torri, copïo a gludo gyda chod VBA


Analluoga swyddogaethau torri, copïo a gludo gyda chod VBA

Gwnewch fel a ganlyn i analluogi'r swyddogaethau torri, copïo a gludo mewn llyfr gwaith Excel.

1. Yn y llyfr gwaith mae angen i chi analluogi'r swyddogaethau torri, copïo a gludo, pwyswch y Alt + F11 allweddi ar yr un pryd i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch ddwywaith Llyfr Gwaith hwn yn y chwith Prosiect cwarel, ac yna copïwch a gludwch y cod VBA isod i'r Y Llyfr Gwaith hwn (Cod) ffenestr. Gweler y screenshot:

Cod VBA: Analluoga'r swyddogaethau torri, copïo a gludo ar yr un pryd yn 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. Yna pwyswch y Alt + Q allweddi i adael y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

Nawr ni allwch dorri na chopïo data o'r llyfr gwaith hwn, yn y cyfamser, ni ellir pastio data rydych chi wedi'i gopïo o daflenni neu lyfrau gwaith eraill i'r llyfr gwaith hwn.

Nodyn: Mae'r swyddogaeth llusgo a gollwng hefyd yn anabl ar ôl rhedeg y cod VBA uchod.


Erthyglau perthnasol:

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
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