comboboxes

A

aqualibra

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.
 
J

Jacob Skaria

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
 
R

Rick Rothstein

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)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top