Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
use selected value from one combobox to populate another combobox
I need to set up 2 ComboBoxes. ComboBox1 contains two choices; "backen tools" or "frontend tools". Depending on the selected choice ComboBox will bring up a list of tools relating to that choice. So what I nee to know is how to pass the selected ComboBox1.Text value to ComboBox2 Once I have the value I can put an 'if' statement in the ComboBox2 cod such as: if passed value = "backend" then ComboBox2.AddItem("tool1") ComboBox2.AddItem("tool2") end if if passed value = "frontend" then ComboBox2.AddItem("tool10") ComboBox2.AddItem("tool11") end if Cheers Robbie:confused -- rjudg ----------------------------------------------------------------------- rjudge's Profile: http://www.excelforum.com/member.php...fo&userid=3298 View this thread: http://www.excelforum.com/showthread.php?threadid=53286 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
use selected value from one combobox to populate another combobox
Assuming your code is behind the userform that contains both ComboBox
controls, you could try this in the Change event for ComboBox1 If Me.Value = "backend" Then With ComboBox2 .AddItem "tool1" .AddItem "tool2" End With Else With ComboBox2 .AddItem "tool10" .AddItem "tool11" End With End If HTH Regards, Garry |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
use selected value from one combobox to populate another combo
Think Gary left out part of his code: (ME refers to the Userform containing
the code or if on a worksheet, the worksheet containing the code module). If Me.Combobox1.Value = "backend" Then With Me.ComboBox2 .AddItem "tool1" .AddItem "tool2" End With Else With Me.ComboBox2 .AddItem "tool10" .AddItem "tool11" End With End If -- Regards, Tom Ogilvy "GS" wrote: Assuming your code is behind the userform that contains both ComboBox controls, you could try this in the Change event for ComboBox1 If Me.Value = "backend" Then With ComboBox2 .AddItem "tool1" .AddItem "tool2" End With Else With ComboBox2 .AddItem "tool10" .AddItem "tool11" End With End If HTH Regards, Garry |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
use selected value from one combobox to populate another combo
Thanks Tom, ...you're absolutely correct.
To the OP: My apologies for the careless omission! Also, you may want to include clearing the ComboBox2 list before adding any items in case the user changes selections in ComboBox1. Otherwise, the new items will be added to any existing items in the list. Also, I added a line to clear the .Value so nothing is selected. Revised (with Tom's correction) to include: If Me.Combobox1.Value = "backend" Then With Me.ComboBox2 .Clear .AddItem "tool1" .AddItem "tool2" End With Else With Me.ComboBox2 .Clear .AddItem "tool10" .AddItem "tool11" End With End If Me.ComboBox2.Value = "" 'make sure nothing is selected Regards, Garry |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do i populate a text box according to selection in combobox? | Excel Worksheet Functions | |||
Populate a Combobox from range. | Excel Programming | |||
Populate combobox | Excel Programming | |||
populate combobox with sheet names | Excel Programming | |||
Populate a combobox | Excel Programming |