Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Okay.. here's the deal, i have a user form in excel that
gathers information. In one section there is a series of six combo boxes. What i have been trying to do is have code in the UserForm_Initialize() sub that adds items to the combo boxes. All six combo boxes need the same information added to them. what i would like to do is something like: for each X in (1,2,3,4,5,6) with Me.ComboBoxX .AddItem "a" .AddItem "b" end with next trying to get it to go through all 6 boxes.. but this is not working and i cant figure out how to get it to work without reapeating the .AddItem list for each and every box. is there a faster way to do it? -keaven |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Keaven,
Load up combobox 1, and then set the List property of each of the other comboboxes to the List property of combobox 1. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "keaven" wrote in message ... Okay.. here's the deal, i have a user form in excel that gathers information. In one section there is a series of six combo boxes. What i have been trying to do is have code in the UserForm_Initialize() sub that adds items to the combo boxes. All six combo boxes need the same information added to them. what i would like to do is something like: for each X in (1,2,3,4,5,6) with Me.ComboBoxX .AddItem "a" .AddItem "b" end with next trying to get it to go through all 6 boxes.. but this is not working and i cant figure out how to get it to work without reapeating the .AddItem list for each and every box. is there a faster way to do it? -keaven |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
with Me.ComboBox1
.AddItem "a" .AddItem "b" end with for i = 2 to 6 me.Controls("Combobox" & i).List = Combobox1.List Next -- Regards, Tom Ogilvy "keaven" wrote in message ... Okay.. here's the deal, i have a user form in excel that gathers information. In one section there is a series of six combo boxes. What i have been trying to do is have code in the UserForm_Initialize() sub that adds items to the combo boxes. All six combo boxes need the same information added to them. what i would like to do is something like: for each X in (1,2,3,4,5,6) with Me.ComboBoxX .AddItem "a" .AddItem "b" end with next trying to get it to go through all 6 boxes.. but this is not working and i cant figure out how to get it to work without reapeating the .AddItem list for each and every box. is there a faster way to do it? -keaven |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Chip, Tom.. thanks for your help, it worked great.
the second part was to have an item be removed from all the other combo boxes once it was selected from another one. this was complicated byt he fact that there was no way to know in what order the comboboxes would be used. This is how i ended up doing it... basically storing the list index of the selection into a variable, then making sure that the other comboboxes didnt have count of zero (since i clear the combobox list after a choice is made), then removing the corresponding list index. This is for the first box, the other five are exactly the same, with the exception of combobox referances of corse: Private Sub StatBox1_Click() ' Lockes the stat choice in, and removes it ' from the other comboboxes Dim strStat As String Dim X As Integer X = Me.StatBox1.ListIndex 'MsgBox X strStat = Me.StatBox1.Value Me.StatBox1.Clear Me.StatBox1.Value = strStat Me.StatBox1.Locked = True Call FindStat(Me.StatBox1.Value, Me.stat1.Value) If (Me.StatBox2.ListCount 0) Then Me.StatBox2.RemoveItem (X) End If If (Me.StatBox3.ListCount 0) Then Me.StatBox3.RemoveItem (X) End If If (Me.StatBox4.ListCount 0) Then Me.StatBox4.RemoveItem (X) End If If (Me.StatBox5.ListCount 0) Then Me.StatBox5.RemoveItem (X) End If If (Me.StatBox6.ListCount 0) Then Me.StatBox6.RemoveItem (X) End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Getting Combo boxes to change options based on other Combo boxes. | New Users to Excel | |||
multiple combo boxes | Excel Discussion (Misc queries) | |||
Multiple combo boxes with unique duplicates showing only | New Users to Excel | |||
Problem Adding new Combo Boxes | Excel Discussion (Misc queries) | |||
multiple combo boxes | Excel Discussion (Misc queries) |