Excel VBA - Disabling copy/cut-paste in workbook

Carl Carl

I'm trying to find a way to prevent copy/cut-pasting in excel cells. I disabled copy/pasting of cells however found a flaw that if a user copies the actual value of the cell he's able to paste thus(In only 1 cell not a range of cells) making the disabled copy/paste useless.

I used the following line of code from another question:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.CutCopyMode = False

Dim UndoList As String

With Application
    .EnableEvents = False
    .ScreenUpdating = False
End With

On Error GoTo ErrExit
UndoList = Application.CommandBars("Standard").Controls("&Undo").List(1)
If Left(UndoList, 5) = "Paste" Or UndoList = "Auto Fill" Then
    MsgBox "Please don't paste values on this sheet." & vbCr & _
           "The action will be reversed.", vbInformation, _
           "Paste is not permitted"
    With Application
        .Undo
        .CutCopyMode = False
    End With
    Target.Select
End If

ErrExit:
With Application
    .ScreenUpdating = True
    .EnableEvents = True
End With
End Sub
nagarajannd

How about using Application.Onkey.

Sub DisableCutCopyPaste()
Application.OnKey "^{c}", "" 'Copy
Application.OnKey "^{v}", "" 'Paste
Application.OnKey "^{x}", "" 'Cut
End Sub

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Loop through a workbook and copy & paste values in to another workbook (VBA, Excel)

Excel VBA - loop over files in folder, copy range, paste in this workbook

excel vba macro: copy and paste the specific column to another workbook

Excel VBA Copy and paste to different workbook at end of existing data

Excel VBA paste special disjoint range from one workbook to another

Excel VBA Cutting rows from workbook1 and paste it in workbook2

Excel VBA - Close workbook

How do I use the Inputbox in VBA to obtain a range from a user from a already open Excel workbook and paste it into another, standardized workbook?

Excel VBA copy specific cells from selected rows and paste specified column other workbook

Excel VBA - Copy range from one sheet paste to all sheets after certain sheet in workbook

VBA Excel paste data from other workbook row by row in transpose way

VBA Excel - copy from multiple various ranges at once and paste in different cell ranges of newly created workbook

VBA to copy from one workbook and paste to another

VBA Macro to copy and paste sheets into new workbook

VBA Copy from workbook and Paste to ThisWorkbook

VBA - Copy-Paste to another workbook

Disabling "cut" from excel with vba

Excel VBA Copy Paste

Excel VBA - Paste as values

Excel Row paste with VBA

Cant paste - Excel VBA

Copy & paste on VBA excel

Excel VBA - Copy Workbook into a new Workbook with the macros

Copy workbook and to paste below another workbook MS Excel

VBA Excel spellchecking for protected workbook

VBA EXCEL - Extract a copy of workbook

VBA Excel - Workbook_SheetChange

Referring to a new workbook in Excel VBA

Excel VBA macro - find the cell location from which cells in two columns match the row and column in another workbook then paste a value