Data Validation Lists

J

Joseph

Hi,

I have two cells with data validation lists. The values in
the second list are populated based on the value selected
in the first list. For eg:

Let A1 = Vegetable, Fruit
If A1 = Vegetable then
B1 = Carrot, Potato

If A1 = Fruit then
B1 = Apple, Grape

Ive made the list to work, with the Indirect () function,
but have one small problem. The first time I select, A1 =
Vegetable and B1 = Carrot, then, if I change A1
to "Fruit", is it possible to clear the contents of the
cell B1 as "Carrot" is not a valid value for "Fruit". Is
this possible without writing a macro ??

Thanks
Joseph
 
B

Bernie Deitrick

Joseph,
Is this possible without writing a macro ??

No. You would need to use the Worksheet's change event to capture the
change in value in Cell A1 to clear cell B1.

Copy the code below, right click on the sheet tab, select "View Code"
then paste the code into the window that appears.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Range("B1").ClearContents
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

Top