ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   poping up a box with choices? (https://www.excelbanter.com/excel-programming/293425-poping-up-box-choices.html)

neowok[_42_]

poping up a box with choices?
 
just wondering if its possible to pop up a box with say 3 choices in it
user selects one of these and an action can then be performed based o
their choice.

i.e. ive got some ovals with text in them, some of these have severa
ref numbers and it would be useful if a user clicks on one of the oval
they get a choice of which number they want. i can then display th
corresponding data row once ive got their choice

--
Message posted from http://www.ExcelForum.com


Dick Kusleika[_3_]

poping up a box with choices?
 
neowok

How about a menu on the right click menu for the shape. You assign the
macro ShowMenu to all the shapes for which you want the menu to appear. One
problem is that you have to left click on the shape before you right click
to the get the menu, or the menu won't show the right data.

Dim aNums As Variant

Sub ShowMenu()

Dim cb As CommandBar
Dim cbb As CommandBarControl
Dim ctl As CommandBarControl
Dim i As Long

Set cb = Application.CommandBars("shapes")

If cb.Controls(1).Caption = "Select Number" Then
Set cbb = cb.Controls(1)
For Each ctl In cbb.Controls
ctl.Delete
Next ctl
'cbb.Reset
Else
Set cbb = cb.Controls.Add(msoControlPopup, , , 1, True)
cbb.Visible = True
cbb.Caption = "Select Number"
End If


aNums = Split(Sheet1.Shapes(Application.Caller).TextFrame. _
Characters(1, 255).Text, ",", , vbTextCompare)

For i = LBound(aNums) To UBound(aNums)
With cbb.Controls.Add(msoControlButton)
.Caption = Trim(aNums(i))
.OnAction = "CatchNumber"
.Style = msoButtonCaption
.Visible = True
End With
Next i

End Sub

Sub CatchNumber()

MsgBox aNums(Application.Caller(1) - 1)

End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.


"neowok " wrote in message
...
just wondering if its possible to pop up a box with say 3 choices in it.
user selects one of these and an action can then be performed based on
their choice.

i.e. ive got some ovals with text in them, some of these have several
ref numbers and it would be useful if a user clicks on one of the ovals
they get a choice of which number they want. i can then display the
corresponding data row once ive got their choice.


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 10:31 AM.

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