Private Sub Worksheet_Activate()
Dim CB As CommandBar
Dim btn As CommandBarButton
Set CB = Application.CommandBars("Cell")
Set btn = CB.Controls.Add(Type:=msoControlButton, Temporary:=True)
With btn
.BeginGroup = True
.Caption = "My Control"
.FaceId = 333
.OnAction = ""
.Style = msoButtonIconAndCaption
.Tag = "Tag1"
End With
End Sub
Private Sub Worksheet_Deactivate()
Dim CB As CommandBar
Dim ctl As CommandBarControl
Set CB = Application.CommandBars("Cell")
For Each ctl In CB.Controls
If ctl.Tag = "Tag1" Then ctl.Delete
Next
End Sub