Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visibility of newsgroup postings Weatherman Charts and Charting in Excel 12 October 21st 09 05:09 AM
Visibility of newsgroup postings [email protected] Excel Worksheet Functions 0 October 20th 09 08:41 PM
Visibility of newsgroup postings [email protected] Charts and Charting in Excel 0 October 20th 09 08:41 PM
controlling worksheets using combo-box Sunil Sagar Excel Worksheet Functions 1 January 28th 09 05:49 AM
Add-In Visibility Trent Argante Excel Discussion (Misc queries) 5 February 13th 08 08:01 PM


All times are GMT +1. The time now is 02:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"