Paste code in thisworkbook(vba code) in excel file
For click example file download:- click here Right click commandbar file download
Note after code paste file save in macro xlsm format and open again
Copy below code
__________________________________________________________
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Contextmenu As CommandBar
Set Contextmenu = Application.CommandBars("Cell")
For Each ctrl In Contextmenu.Controls
If ctrl.Tag = "my_cell_control_tag" Then
ctrl.Delete
End If
Next ctrl
End Sub
Private Sub Workbook_Open()
Dim Contextmenu As CommandBar
Set Contextmenu = Application.CommandBars("Cell")
With Contextmenu.Controls.Add(Type:=msoControlButton, before:=1)
.OnAction = "'" & ThisWorkbook.Name & "'!hello" ' hello is macro name
.FaceId = 351
.Caption = "hello"
.Tag = "my_cell_control_tag"
End With
End Sub
____________________________________________________________
and Create a hello name macro in module
Sub hello()
MsgBox "hello nitin world"
End Sub