Disabling "cut" function - version 2003/2007


W

wlam

Does any one know how to disable "cut" function in a protected worksheet? By
allowing cutting in unprotected cell, it is messing up the formula that I put
in the protected cell which is related to that unprotected cell.
 
Ad

Advertisements

G

Garreth Lombard

Hi there wlam,

Paste this code in the "ThisWorkbook" VBA code module of the workbook you
want to protect.

Code is below.
-----------------------

Const DisableCutOperations As Boolean = True

Private Sub Workbook_WindowActivate(ByVal Wn As Excel.Window)
If DisableCutOperations = False Then Exit Sub
Set CutButton = Application.CommandBars("Worksheet Menu Bar"). _
Controls("edit").CommandBar.Controls("Cut")
CutButton.OnAction = "ThisWorkbook.DisableCut"
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Excel.Window)
Set CutButton = Application.CommandBars("Worksheet Menu Bar"). _
Controls("edit").CommandBar.Controls("Cut")
CutButton.OnAction = Cut
End Sub

Sub DisableCut()
If DisableCutOperations = False Then Exit Sub
If ActiveWorkbook.Name = ThisWorkbook.Name Then
dummy = MsgBox("Do NOT use the cut function in this Workbook please.
", _
vbInformation, ActiveWorkbook.Name)
Exit Sub
Else: Selection.Cut
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top