How to create a Pop Up Menu in Microsoft Excel 2007 2010 Instructions

Alex C · 46,303 views
This video shows a step by step process on creating a popup menu in Microsoft Excel 2010.

Public The_Menu As CommandBar
Function CreateSubMenu() As CommandBar

Const pop_up_menu_name = "Pop-up Menu"

Dim the_command_bar As CommandBar
Dim the_command_bar_control As CommandBarControl

'Deletes any CommandBars that may be present
For Each menu_item In CommandBars
If menu_item.Name = pop_up_menu_name Then
End If

''Add our popup menu to the CommandBars collection
Set the_command_bar = CommandBars.Add(Name:=pop_up_menu_name, Position:=msoBarPopup, MenuBar:=False, Temporary:=False)

'*****Menu Options*****
Set the_command_bar_control = the_command_bar.Controls.Add
the_command_bar_control.Caption = "Run Macro Hello World!"
the_command_bar_control.OnAction = "TestMacro"
'To add more items to the menum simply copy the 3 lines above and paste below
'All you need to do is change the caption and onaction macro names.

Set CreateSubMenu = the_command_bar

End Function
Sub TestMacro()
MsgBox "Hello World"
End Sub
Sub Button_Clicked()
Set The_Menu = CreateSubMenu
End Sub