change list in combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a combo box called cb1 with a list of values (p1:p2). I have a secong
combo box cb2 that i would like the list to change depending on what is
chosen in cb1. If the first option is chosen I'd like the data in cells Q1:Q8
to be the list and if the second option is chosen I'd like R1:R6 to be the
list in CB2. Thanks for any help.

Qaspec
 
Hi,

Assuming your comboboxes are in a userform, then use:

Private Sub cb1_Change()
Dim pos As Long
pos = cb1.ListIndex

If pos = 0 Then 'Case first item is chosen
cb2.RowSource = "Sheet1!Q1:Q8"
ElseIf pos = 1 Then 'Case second item is chosen
cb2.RowSource = "Sheet1!R1:R6"
Else 'Case else
cb2.RowSource = ""
End If
End Sub
 

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

Similar Threads


Back
Top