
Originally Posted by
singhabhijitkumar
Hi, thanks. I have two problems with this. Firstly, is that I am unable to modify the named list, or delete it. Secondly, the values don't get resetted to blank if i change my parent value in drop down list. For exampl I have selected FRUIT in my parent dropdown and APPLE in my dependent dropdown. Now if I change FRUIT to VEGETABLE, the dependant cell still shows APPLE. I want it to be resetted to blank.
Please could you help
use
Private Sub ComboBox1_change()
Dim t As Range
Dim i As Integer
Dim ws As Worksheet
Set ws = ActiveWorkbook.Worksheets("Sheet1")
ComboBox1.ShowDropButtonWhen = fmShowDropButtonWhenAlways
If ComboBox1.Value = "" Then ComboBox2.Clear
If ComboBox1.ListIndex > 0 Then ComboBox2.Clear
If ComboBox1.ListIndex = 0 Then
ComboBox2.Clear
ComboBox2.Value = ""
ElseIf ComboBox1.ListIndex = 1 Then
ComboBox2.Clear
For Each tower In ws.Range("Range1")
With Me.ComboBox2
.AddItem t.Value
.List(.ListCount - 1, 1) = t.Offset(0, 1).Value
End With
Next t
ElseIf ComboBox1.ListIndex = 2 Then
ComboBox2.Clear
For Each tower In ws.Range("Range2")
With Me.ComboBox2
.AddItem t.Value
.List(.ListCount - 1, 1) = t.Offset(0, 1).Value
End With
Next t
ElseIf ComboBox1.ListIndex = 3 Then
ComboBox2.Clear
For Each tower In ws.Range("Range3")
With Me.ComboBox2
.AddItem t.Value
.List(.ListCount - 1, 1) = t.Offset(0, 1).Value
End With
Next t
End If
End Sub
Hope this helps...
Bookmarks