Combine a combobox with logic

  • Thread starter Thread starter THILL
  • Start date Start date
T

THILL

Is there a way to program excel to pull a specifec list based on a cells
value ie. if a1 = 1 pull data for combox from list 1, if a1 = 2 pull data
from list 2 ect, ect
 
hi
yes
you can use the gotfocus event to set the listfillrange of a sheet combo box
but your list have to be on the sheet somewhere.
example
Private Sub ComboBox1_GotFocus()
If Range("A1").Value = 1 Then
ComboBox1.ListFillRange = "G1:G5"
Else
If Range("A1").Value = 2 Then
ComboBox1.ListFillRange = "H1:H5"
Else
ComboBox1.ListFillRange = "I1:I5"
End If
End If
End Sub
with a form combo box(ON A FORM, NOT THE SHEET), i think it's the row source.
you can also use the additem method. look that up in vb help.

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

Back
Top