ComboBox1 ComboBox2

S

samanco

I have two ComboBoxes on a VBA Userform, what I want is for users to
select a major Catagory from combobox1, which then changes the list
value in ComboBox2. I use named ranges on a hidden worksheet which
contrains lists of constants. I cannot get combobox 2 to recognise
the value of ComboBox 1 as the name of a valid list ??

I have tried a number of methods, such as:

If ComboBox 1 value = "Prada" then
ComboBox2.RowScource = "Shoes"
else if ComboBox 1 value = "Vesace" then
ComboBox2.RowScource = "suits"
end if
etc

and the Select Case method

i,e.
Select case_designer
case 1 = prada
case 2 = versace

etc

however try and try again I cannot get this to work

has any one got any working sub that I can have a look at as an
example please?
 
G

Guest

End Subhi,
I set up three lists.
list 1 at A10:A11 with the words Letter and number.
combobox1's listfillrange = A10:A11
list 2 at B10:B14 with letters a,b,c,d,e
list 3 at C10:C14 with numbers 1,2,3,4,5
I have 2 combo boxes at B4 named CB1 and C4 named CB2
I put this code in Combobox1(CB1)

Private Sub CB1_Change()
If CB1.Value = "letter" Then
CB2.ListFillRange = "B10:B14"
Else
If CB1.Value = "number" Then
CB2.ListFillRange = "C10:C14"
End If
End If
End Sub

tested. worked for me. i'm using xp
I suppose select case would work but i did not test that.
hope this helped.
regards
FSt1
 
G

Guest

hi again,
sorry. your are using a form.
I created a form with 2 combo boxes named CB1 and CB2.
I set up three lists on sheet 2
list 1 at A10:A11 with the words Letter and number.
combobox1's Rowsource = sheet2!A10:A11
list 2 at Sheet2!B10:B14 with letters a,b,c,d,e
list 3 at Sheet2!C10:C14 with numbers 1,2,3,4,5
I put this code in Combobox1(CB1)

Private Sub CB1_Change()
If CB1.Value = "Letter" Then
CB2.RowSource = "Sheet2!B10:B14"
Else
If CB1.Value = "Number" Then
CB2.RowSource = "Sheet2!C10:C14"
End If
End If
End Sub

Tested. works.
Regards
FSt1
 

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