Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combo box controlling visibility
I have a user form in VB that contains multiple
comboboxes. I am looking to haave the first combobox control the Visible property of the other boxes. any help is appreciated |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combo box controlling visibility
Private Sub combobox1_Click()
dim cbox = MSForms.Combobox for each ctrl in Userform1.Controls if typeof ctrl is MsForms.Combobox then set cbox = ctrl if right(cbox.name,1) < 1 then cbox.visible = False end if end if Next Controls("Combobox" & combobox1.Listindex + 2).Visible = True Me.Repaint End Sub would be a guess at what you want. -- Regards, Tom Ogilvy chis wrote in message ... I have a user form in VB that contains multiple comboboxes. I am looking to haave the first combobox control the Visible property of the other boxes. any help is appreciated |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combo box controlling visibility
Hello again. Ithink I might have been a little vague with what I was
looking for. I have combobox1 and it has a few variables. When the user selects variable 1 I would like combobox2 to become visible. If they choose variable 2 then combobox3 becomes visible and so on. I don't knw why I didn't put it that way the first time. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combo box controlling visibility
That is what I assumed, that is what I gave you although I hide all but
combobox1 first and then the appropriate combobox is made visible. It assumes comboboxes are named combobox1, combobox2, etc so if the select item is the first item, then listindex is zero and zero plus 2 is 2, so combobox & (listindex + 2) is made visible (combobox2). -- Regards, Tom Ogilvy "Chris LeBlanc" wrote in message ... Hello again. Ithink I might have been a little vague with what I was looking for. I have combobox1 and it has a few variables. When the user selects variable 1 I would like combobox2 to become visible. If they choose variable 2 then combobox3 becomes visible and so on. I don't knw why I didn't put it that way the first time. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combo box controlling visibility
Hi there again. I pasted the code into the form's codes and I receive
an error. The error is that "dim cbox = MSForms.ComboBox" is a compile error:Syntax error. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combo box controlling visibility
dim cbox = MSForms.Combobox
should be dim cbox as MSForms.Combobox while I apologize for the typo, should you really be attempting this? Anyway, I copied this form a working USERFORM Private Sub combobox1_Click() Dim cbox As MSForms.ComboBox For Each ctrl In UserForm1.Controls If TypeOf ctrl Is MSForms.ComboBox Then Set cbox = ctrl If Right(cbox.Name, 1) < 1 Then cbox.Visible = False End If End If Next Controls("Combobox" & ComboBox1.ListIndex + 2).Visible = True Me.Repaint End Sub Private Sub UserForm_Initialize() Dim cbox As MSForms.ComboBox For i = 1 To 5 For j = 1 To 4 Controls("ComboBox" & i).AddItem "Item " & j Next Next For Each ctrl In UserForm1.Controls If TypeOf ctrl Is MSForms.ComboBox Then Set cbox = ctrl If Right(cbox.Name, 1) < 1 Then cbox.Visible = False End If End If Next End Sub Tested in xl97, SR2 -- Regards, Tom Ogilvy Chris wrote in message ... Hi there again. I pasted the code into the form's codes and I receive an error. The error is that "dim cbox = MSForms.ComboBox" is a compile error:Syntax error. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combo box controlling visibility
It is probably over my head but I have been trying to figure a quick way
to do what has taken an entire page of activex controls. Thanks for all the help. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Visibility of newsgroup postings | Charts and Charting in Excel | |||
Visibility of newsgroup postings | Excel Worksheet Functions | |||
Visibility of newsgroup postings | Charts and Charting in Excel | |||
controlling worksheets using combo-box | Excel Worksheet Functions | |||
Add-In Visibility | Excel Discussion (Misc queries) |