Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That did the trick, Many thanks.
-- Cheers Nigel "keepITcool" wrote in message .com... Sub tbHandler() With Application.CommandBars.ActionControl Select Case .Parameter Case 1: MsgBox "Do Summary" Case 2: MsgBox "Do Targets" Case 8: MsgBox .ListIndex & .List(.ListIndex) End Select End With End Sub also: look at naming conventions for variables... your original had toolbars named rs (recordset?) below has a worksheet named ctl (control). also: dim your variables at the top of the procedure. note: the onaction parameter s/b set last, AFTER adding the listitems. Dim cel, rng ....... With .Controls.Add(Parameter:=8, Temporary:=True, _ Type:=msoControlDropdown) .Caption = "Region" With Worksheets("Control") Set rng = .Range(.Cells(3, 2), .Cells(Rows.Count, 2).End(xlUp)) End With For Each cel In rng .AddItem cel.Value Next .ListIndex = 1 .OnAction = ThisWorkbook.Name & "!tbhandler" End With -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam Nigel wrote : Hi keepItCool That fixed it and gave me some insight how to handle parameters in the actioncontrol. That is neat! I have a supplementary questions... Using this method I have added another control (dropdown box) and filled the values from a worksheet list (that works), given it a parameter of 8. How do I pass the value of the listindex from the control to the tbhandler or do I need to use something else? ........... With .Controls.Add(Parameter:=8, Type:=msoControlDropdown, Temporary:=True) .Caption = "Region" Dim ctl As Worksheet Set ctl = Sheets("Control") Dim LrowTlist As Integer, xi As Integer LrowTlist = ctl.Cells(Rows.Count, "B").End(xlUp).Row .Style = msoButtonAutomatic .OnAction = ThisWorkbook.Name & "!tbhandler" For xi = 3 To LrowTlist .AddItem ctl.Cells(xi, 2).Value Next xi .ListIndex = 1 End With ........ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Toolbar problems | Excel Discussion (Misc queries) | |||
Toolbar/Menu Bar | Excel Discussion (Misc queries) | |||
Can't find menu toolbar | Excel Discussion (Misc queries) | |||
Toolbar Problems | Excel Programming | |||
icon in menu toolbar | Excel Programming |