Friday, May 4, 2018

how to add macro shortcut in excel menu bar - vbatip#48







1. add two form controls and assign below procedures / macros to them. 







Sub
AddMenuItem()

Dim item As
CommandBarControl
Call
RemoveMenuItem
Set item =
CommandBars(1).Controls("Format").Controls.Add
item.Caption
= "&Run Macro1"
item.OnAction
= "RunMacro1"
item.BeginGroup
= True

End Sub

Sub
RemoveMenuItem()
On Error
Resume Next
CommandBars(1).Controls("Format").Controls("&Run
Macro1").Delete
End Sub



2. rename your macro procedure name to "RunMacro1" and click on AddMenuItem button. 



you would see your shortcut under addins. 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.