Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
create a second combo box from a first combo box
How do I create a second combo box, from a first one? I am trying to make a
hierarchical sheet listing, so the first box has file names, and the second should show sheet names. I am passing the top, left, width and height, to offset the position of the second box, and the name of the first so I can name the second one, modifying the name to reflect that it is a 'sub' box. For example, if the first is named,"Simpsons", I would like the second to be named "SimpsonsSub". I do not want the second box present unless a choice is made from the first box. Is this possible? Wazooli |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
create a second combo box from a first combo box
Recording a macro while adding a combobox provides this code
ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1", Link:=False, _ DisplayAsIcon:=False, Left:=201, Top:=229.5, Width:=71.25, Height:= _ 16.5).Select so you could do Private Sub Simpsons_Click() Dim cb As MsForms.ComboBox Dim obj1 As OLEObject Dim obj As OLEObject On Error Resume Next ActiveSheet.OLEObjects("SimpsonsSub").Delete On Error GoTo 0 Set obj1 = ActiveSheet.OLEObjects("Simpsons") Set obj = ActiveSheet.OLEObjects.Add( _ ClassType:="Forms.ComboBox.1", _ Link:=False, _ DisplayAsIcon:=False, _ Left:=obj1.Left + obj1.Width + 5, _ Top:=obj1.Top, _ Width:=obj1.Width, _ Height:=obj1.Height) Set cb = obj.Object cb.Name = "SimpsonsSub" End Sub You would then need to fill it based on the selection in Simpsons Not sure how you want to trigger a deletion. But use code as shown since I delete any existing box to avoid duplicates. If you want to create event code for it, you can look at Chip Pearson's site http://www.cpearson.com/excel/vbe.htm -- Regards, Tom Ogilvy "Wazooli" wrote in message ... How do I create a second combo box, from a first one? I am trying to make a hierarchical sheet listing, so the first box has file names, and the second should show sheet names. I am passing the top, left, width and height, to offset the position of the second box, and the name of the first so I can name the second one, modifying the name to reflect that it is a 'sub' box. For example, if the first is named,"Simpsons", I would like the second to be named "SimpsonsSub". I do not want the second box present unless a choice is made from the first box. Is this possible? Wazooli |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
create a second combo box from a first combo box
perfect -thanks tom
"Tom Ogilvy" wrote: Recording a macro while adding a combobox provides this code ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1", Link:=False, _ DisplayAsIcon:=False, Left:=201, Top:=229.5, Width:=71.25, Height:= _ 16.5).Select so you could do Private Sub Simpsons_Click() Dim cb As MsForms.ComboBox Dim obj1 As OLEObject Dim obj As OLEObject On Error Resume Next ActiveSheet.OLEObjects("SimpsonsSub").Delete On Error GoTo 0 Set obj1 = ActiveSheet.OLEObjects("Simpsons") Set obj = ActiveSheet.OLEObjects.Add( _ ClassType:="Forms.ComboBox.1", _ Link:=False, _ DisplayAsIcon:=False, _ Left:=obj1.Left + obj1.Width + 5, _ Top:=obj1.Top, _ Width:=obj1.Width, _ Height:=obj1.Height) Set cb = obj.Object cb.Name = "SimpsonsSub" End Sub You would then need to fill it based on the selection in Simpsons Not sure how you want to trigger a deletion. But use code as shown since I delete any existing box to avoid duplicates. If you want to create event code for it, you can look at Chip Pearson's site http://www.cpearson.com/excel/vbe.htm -- Regards, Tom Ogilvy "Wazooli" wrote in message ... How do I create a second combo box, from a first one? I am trying to make a hierarchical sheet listing, so the first box has file names, and the second should show sheet names. I am passing the top, left, width and height, to offset the position of the second box, and the name of the first so I can name the second one, modifying the name to reflect that it is a 'sub' box. For example, if the first is named,"Simpsons", I would like the second to be named "SimpsonsSub". I do not want the second box present unless a choice is made from the first box. Is this possible? Wazooli |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I create a combo box that is tied to another combo box? | Excel Worksheet Functions | |||
linking a form combo box... results from the combo box to another | Excel Discussion (Misc queries) | |||
combo reference on another combo box for picking address etc. | Excel Worksheet Functions | |||
"Combo Box - getting control combo box to stick in place in worksh | Excel Discussion (Misc queries) | |||
"Combo Box - getting control combo box to stick in place in worksh | Excel Discussion (Misc queries) |