PDA

View Full Version : VBA dependent drop down list



stefanlupasc
01-11-2019, 04:03 AM
Hi,

I have looked over different forums and actually tried this but didnt work.

I want my dependent drop down list to clear when parent cell changes( which is not a dropdown)
The thing is that in the parent cell there is a formula which is somehow dependent on a certain criteria.

I have inserted this code below, which apparently works if i change the parent cell manualy, but when the parent cell changes based on the criteria the dependent drop down does not react to this.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Column = 43 Then
If Target.Validation.Type = 3 Then
Application.EnableEvents = True
Target.Offset(0, 1).ClearContents
End If
End If


exitHandler:
Application.EnableEvents = True
Exit Sub


End Sub


Could somebody help me sort this out?

Thank you

MartinGM
01-11-2019, 04:42 AM
In a rush, so apologies for the terse answer !

The reason it isn't working as you expect is that the non-manual changes don't trigger the Worksheet Change Event :(

Look for another way to force it to run, or for a different Event to use.

PS I didn't see the Application.EnableEvents = False statement at the beginnning of the code ? You must always include this in Change Event code or you risk infinite loops !