Combo Box Help

T

towl

Hi all, hopefully someone can help me out.

I have created a combo box (from the control toolbox), and have
assigned a linked cell and a list fill range.

I now want to create a 2nd combo box, that will bring back a second set
of results based on the outcome of the first combo box.

I know this can be done using data validation, however I am trying to
get it done through VBA, so I can design a form for my colleagues to
use.

If the above was unclear, think Car manufacturers and models, depending
on what car manufactuer is selected (viabox 1), I want only certain
models to be shown in box2.

Any help would be appreciated.
 
T

Tom Ogilvy

In the click even of the first combobox, populate the second using add item


Private Sub Combobox1_Click()
Dim rng as Range
set rng = Range(combobox1.ListFillRange)
' combobox2 should not have a listfillrange assignment
Combobox2.Clear
for each cell in rng
if cell.Value = Combobox1.Value then
Combobox2.AddItem cell.offset(0,1).Value
end if
Next
End Sub
 
T

towl

Thanks for the help Tom, but still doesn't seem to be working,


I have assigned a list name in Excel, that corresponds to the names i
the combobox1 list, and it is this that I am wanting to pick up, gues
I am trying to run before I can walk, as only started using Vba las
week.

Does anyone else have any ideas
 
T

Tom Ogilvy

Private Sub Combobox1_Click()
If Combobox1.ListIndex <> -1 then
Combobox2.List = Range(Combobox1.Value).Value
End if
End Sub

If you tell the whole story in the beginning, you increase your chances of
getting a usable answer. Otherwise we have to guess to fill in the blanks.
 

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

Combo box 0
Request Form - Alert Team Member 0
combo box 2
Combo or list box 0
synchronize combo boxes 7
Combo boxes in excel 6
Combo box listing in same colour as list 0
Combo box in user form 5

Top