How to attach function to a custom Menubar?

M

Malcom Jazz

I have created a custom Menubar with 3 buttons in it. I got the code
from this NG posted by Bert. I would like to attach the UDF I have
written with these buttons. How to attach the UDF function to button?
I want
when clicked on button created, Formula wizard should come up
displaying UDF areguments. It is the popup you can see after click on
fx, selecting a function and click okey.

Menubar code written by Bert is as below(modified to my requirement)

Sub Add_Menubar()
Dim mb As CommandBar
Dim MenuName As String

Dim Cap(1 To 4)
Dim Act(1 To 4)

Cap(1) = "Growth"
Act(1) = Growth 'Growth is custom function or UDF
Cap(2) = "SP Incentive"
Act(2) = "SP_Incentive" 'SP_Incentiveis also UDF function.

MenuName = "&Salary"
MenuBars(xlWorksheet).Menus.Add Caption:=MenuName, before:="Help"

With MenuBars(xlWorksheet).Menus(MenuName).MenuItems
Add Caption:=Cap(1), OnAction:=Act(1)
Add Caption:=Cap(2), OnAction:=Act(2)
End With
End Sub


Regards,
Malcom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top