Custom Menu and submenu textbox

stakar

Active Member
Joined
Mar 6, 2004
Messages
333
hi there!!!
I have a problem and i cant solve it.
I have the following code that is creating a menu.
I want when the submenu appears ("Choose Draws" in this occasion) and select it, to appears an textbox that it will read a value from the cell B1.
Then, when the user inserts a value, must be validated through a specific list which it will be, for example, in a range of cells A1:A10 with numbers 10 to 20. At last if the value is accepted will be copied to cell B1.
If the user press Esc, or leave the box empty then the value will be the same as before.

Thanks

-------------------------------------------------------------------------------
Option Explicit

Dim cbMenu As CommandBarControl
Dim cbSubMenu As CommandBarControl
Public MenuSeries
Public DrawsChoice As CommandBarComboBox

Sub CreateMenu()
' creates a new menu.
' can also be used to create commandbarbuttons
' may be automatically executed from an Auto_Open macro or a Workbook_Open eventmacro
RemoveMenu ' delete the menu if it already exists
' create a new menu on an existing commandbar (the next 6 lines)
Set cbMenu = Application.CommandBars(1).Controls.Add(msoControlPopup, , , , True)
With cbMenu
.Caption = "&Joker"
.Tag = "JokerTag"
.BeginGroup = False
End With
' or add to an existing menu (use the next line instead of the previous 6 lines)
'Set cbMenu = Application.CommandBars.FindControl(, 30007) ' Tools-menu
If cbMenu Is Nothing Then Exit Sub ' didn't find the menu...

' add a submenu to the submenu
Set cbSubMenu = cbMenu.Controls.Add(msoControlPopup, 1, , , True)
With cbSubMenu
.Caption = "&Choose Draws"
.Tag = "SubMenu2"
End With
'---
Set DrawsChoice = cbSubMenu.Controls.Add(msoControlEdit)
With DrawsChoice
.Caption = "::"
.OnAction = "Draws_Selection"

End With
End Sub

Sub RemoveMenu()
' may be automatically executed from an Auto_Close macro or a Workbook_BeforeClose eventmacro
DeleteCustomCommandBarControl "JokerTag" ' deletes the new menu
End Sub

Private Sub DeleteCustomCommandBarControl(CustomControlTag As String)
' deletes ALL occurences of commandbar controls with a tag = CustomControlTag
On Error Resume Next
Do
Application.CommandBars.FindControl(, , CustomControlTag, False).Delete
Loop Until Application.CommandBars.FindControl(, , CustomControlTag, False) Is Nothing
On Error GoTo 0
End Sub
------------------------------------------------------------------------------
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,224,583
Messages
6,179,683
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top