Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars.FindControl(ID:=1964).Reset
End Sub
Private Sub Workbook_Open()
Application.CommandBars.FindControl(ID:=1964).OnAction = "Customise"
End Sub
Public Sub Customise()
' Change the Book,Sheet and Cell adresses to meet your data arrangement.
If ActiveWorkbook Is Workbooks("Book1.xls") Then
If ActiveSheet Is Worksheets("Sheet1") Then
If ActiveCell.Address = "$A$1" Then
If ActiveSheet.ProtectContents = True Then
CommandBars.FindControl(ID:=1964).OnAction = "CustomClear"
Exit Sub
End If
End If
End If
End If
CommandBars.FindControl(ID:=1964).Reset
End Sub
Public Sub CustomClear()
ActiveSheet.Unprotect
With ActiveCell
.ClearComments
.ClearContents
.ClearFormats
.ClearNotes
.ClearOutline
.Locked = False
End With
ActiveSheet.Protect
End Sub