ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   comboboxes (https://www.excelbanter.com/excel-programming/433756-comboboxes.html)

aqualibra

comboboxes
 
I have 5 comboboxes each has numbers 1 to 5

If combobox1 has 1 then the remaining boxes dropdown menu cannot show 1 and
so on.

There is no order in which the combobxes will be selected.

For eg: Combobox1 has been filled first with say option 4.
next I decide to fill combobox 4. The drop down menu for this should show on
1, 2, 3,5.

Is this possible.

Thanks.



Jacob Skaria

comboboxes
 
Try the below code behind the userform after placing 5 comboboxes in your
userform.


Private Sub ComboBox1_DropButtonClick()
Fillcombo
End Sub
Private Sub ComboBox2_DropButtonClick()
Fillcombo
End Sub
Private Sub ComboBox3_DropButtonClick()
Fillcombo
End Sub
Private Sub ComboBox4_DropButtonClick()
Fillcombo
End Sub
Private Sub ComboBox5_DropButtonClick()
Fillcombo
End Sub

Sub Fillcombo()
Dim blnFound As Boolean, strTemp As String

strTemp = Me.ActiveControl.Object.Text
Me.ActiveControl.Object.Clear
Me.ActiveControl.Object.Text = strTemp
For intTemp = 1 To 5
blnFound = False
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.ComboBox Then
If Me.ActiveControl.Name < ctrl.Name Then
If ctrl.Text = CStr(intTemp) Then blnFound = True: Exit For
End If
End If
Next ctrl
If blnFound = False Then _
Me.ActiveControl.Object.AddItem intTemp
Next
End Sub



If this post helps click Yes
---------------
Jacob Skaria


"aqualibra" wrote:

I have 5 comboboxes each has numbers 1 to 5

If combobox1 has 1 then the remaining boxes dropdown menu cannot show 1 and
so on.

There is no order in which the combobxes will be selected.

For eg: Combobox1 has been filled first with say option 4.
next I decide to fill combobox 4. The drop down menu for this should show on
1, 2, 3,5.

Is this possible.

Thanks.



Rick Rothstein

comboboxes
 
Do you have a method for the user to clear all the TextBoxes so he/she can
start over (for example, if they click the wrong entry in a ComboBox by
mistake)?

--
Rick (MVP - Excel)


"aqualibra" wrote in message
...
I have 5 comboboxes each has numbers 1 to 5

If combobox1 has 1 then the remaining boxes dropdown menu cannot show 1
and
so on.

There is no order in which the combobxes will be selected.

For eg: Combobox1 has been filled first with say option 4.
next I decide to fill combobox 4. The drop down menu for this should show
on
1, 2, 3,5.

Is this possible.

Thanks.





All times are GMT +1. The time now is 07:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com