Greetings all
Before anything my apologies if this was asked before, I was looking for something similar but did not find anything, also if fair to inform you that I am completely illiterate about VBA, this code I copied from this forum once I was looking for help
I use the following code to stop my friends from deleting a specific sheet, it use to work just fine, but for some reason, it’s not working since we update to excel 2010.
‘<Sheet code >
Private Sub Worksheet_Activate()
Dim CB As CommandBar
Dim Ctrl As CommandBarControl
For Each CB In Application.CommandBars
Set Ctrl = CB.FindControl(ID:=847, recursive:=True)
If Not Ctrl Is Nothing Then
Ctrl.OnAction = "RefuseToDelete"
Ctrl.State = msoButtonUp
End If
Next
End Sub
Private Sub Worksheet_Deactivate()
Dim CB As CommandBar
Dim Ctrl As CommandBarControl
For Each CB In Application.CommandBars
Set Ctrl = CB.FindControl(ID:=847, recursive:=True)
If Not Ctrl Is Nothing Then Ctrl.OnAction = ""
Next
End Sub
‘<Module code>
Public Sub RefuseToDelete()
MsgBox "This Sheet cannot be deleted", _
Buttons:=vbExclamation, _
Title: =" This Sheet cannot be deleted!"
End Sub
I hope you can help me with this.
thanks
Bookmarks