Filling drop down box

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

Guest

hi,

I have a drop down box in a cell. Based on a value of
anohter cell I have to fill my drop down box. what i mean
is, say if
GreeNPackage is "No" then I want the drop down box to fill
a range of values. But if the GreeNPackage is "Yes" then I
want the drop down box to fill another set of values. how
can i do this?

plenty of thanks
 
Range D2 is the GreeNPackage value. C5:C7 contains values for yes, D5:D7
contains values for no.


Private Sub Worksheet_Change(ByVal Target As Range)

If (Range("D2") = "yes") Then
ComboBox1.ListFillRange = "C5:C7"
ElseIf (Range("D2") = "no") Then
ComboBox1.ListFillRange = "D5:D7"
Else
ComboBox1.ListFillRange = ""
End If


End Sub


- Mangesh
 
Instead of drop down you can use data validation list and create to
set of range names:

First will have value yes and no and then we will have to create to
other ranged names, named yes and no. in those ranges you keep your
parameters that you want to show as option to users.

Then in the cells where you want to have yes/no answer you set data
validation to you Ye/no named range. Then in the cell where you want
to show values for yes or no, you set data validation to
=(indirect([Address of yes/no cell]). So when the user is selecting
let's say yes, the list validation will be set by indirect to named
range yes.

This method will avoid writing any VB code..

If any questions, contact me.

Regards,

Nick
 

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