ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   maximum number of Right-click options (https://www.excelbanter.com/excel-programming/349254-maximum-number-right-click-options.html)

Paulymon

maximum number of Right-click options
 
I want to use the right click function to allow a user to select a machine
code. There are 48 machine codes but when I write the code it only displays
25 in the right-click menu, is there a way beyond this limitation?

If not, what are my other options?

Chip Pearson

maximum number of Right-click options
 
I would put a combobox dropdown on the right-click menu. E.g.,


Sub AAA()

Dim Ctrl As Office.CommandBarComboBox
Set Ctrl = Application.CommandBars("Cell").Controls.Add( _
Type:=msoControlComboBox, temporary:=True)
With Ctrl
..Caption = "Machine ID"
..AddItem "A"
..AddItem "B"
..AddItem "C"
..OnAction = "DoMachine"
End With

End Sub

Sub DoMachine()

With Application.CommandBars.ActionControl
ActiveCell.Value = .List(.ListIndex)
End With

End Sub




--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Paulymon" wrote in message
...
I want to use the right click function to allow a user to select
a machine
code. There are 48 machine codes but when I write the code it
only displays
25 in the right-click menu, is there a way beyond this
limitation?

If not, what are my other options?




Paulymon

maximum number of Right-click options
 
That worked nicely, thank you. Since this is the only item on the right
click menu is there a way to automatically expand the combo box so it shows
the list as if the user has already clicked on the down arrow?

"Chip Pearson" wrote:

I would put a combobox dropdown on the right-click menu. E.g.,


Sub AAA()

Dim Ctrl As Office.CommandBarComboBox
Set Ctrl = Application.CommandBars("Cell").Controls.Add( _
Type:=msoControlComboBox, temporary:=True)
With Ctrl
..Caption = "Machine ID"
..AddItem "A"
..AddItem "B"
..AddItem "C"
..OnAction = "DoMachine"
End With

End Sub

Sub DoMachine()

With Application.CommandBars.ActionControl
ActiveCell.Value = .List(.ListIndex)
End With

End Sub




--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Paulymon" wrote in message
...
I want to use the right click function to allow a user to select
a machine
code. There are 48 machine codes but when I write the code it
only displays
25 in the right-click menu, is there a way beyond this
limitation?

If not, what are my other options?





Chip Pearson

maximum number of Right-click options
 
I don't believe this is possible.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Paulymon" wrote in message
...
That worked nicely, thank you. Since this is the only item on
the right
click menu is there a way to automatically expand the combo box
so it shows
the list as if the user has already clicked on the down arrow?

"Chip Pearson" wrote:

I would put a combobox dropdown on the right-click menu. E.g.,


Sub AAA()

Dim Ctrl As Office.CommandBarComboBox
Set Ctrl = Application.CommandBars("Cell").Controls.Add( _
Type:=msoControlComboBox, temporary:=True)
With Ctrl
..Caption = "Machine ID"
..AddItem "A"
..AddItem "B"
..AddItem "C"
..OnAction = "DoMachine"
End With

End Sub

Sub DoMachine()

With Application.CommandBars.ActionControl
ActiveCell.Value = .List(.ListIndex)
End With

End Sub




--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Paulymon" wrote in
message
...
I want to use the right click function to allow a user to
select
a machine
code. There are 48 machine codes but when I write the code
it
only displays
25 in the right-click menu, is there a way beyond this
limitation?

If not, what are my other options?








All times are GMT +1. The time now is 01:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com