• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to disable "Delete" worksheet

Villalobos

Active Member
Hello,

I would like to avoid that the user can delete a specified worksheet. Could somebody help me in that how is it possible to disable the "Delete" function? The worksheet should be remain editable.

Thanks in advance the reply!
 
Hello Narayan,

Thank you the link. Unfortunately I would have a problem, I followed the instructions but if I right click on Worksheet tab and select the Delete then the function remains enabled. May be I doing something wrong?

I have place the code in sheets module.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim CommBarTmp, Commbar As CommandBar
For Each Commbar In Application.CommandBars
  Set CommBarTmp = Commbar.FindControl(ID:=847, recursive:=True)
  If Not CommBarTmp Is Nothing Then CommBarTmp.Enabled = True
Next
End Sub
 

Attachments

  • test.xlsm
    14.1 KB · Views: 4
Hi ,

I think it should be :
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
            Dim CommBarTmp As CommandBarControl, Commbar As CommandBar

            For Each Commbar In Application.CommandBars
                Set CommBarTmp = Commbar.FindControl(ID:=847, recursive:=True)
                If Not CommBarTmp Is Nothing Then CommBarTmp.Enabled = False
            Next
End Sub
Narayan
 
Back
Top