Help with a macro: Reset depending data validation lists


Hi friends from the forum, my question is as follows:

I got a piece of Vba code from one of the interesting youtube videos of Leila Gharani.

It´s great but I need to extend its capabilities furthermore.

After tuning it up with my needs, what this macro does is resetting to blank value a serial of depending drop-down -data Validation- lists in a range and it does it with the event  - Change(ByVal Target As Range) - so when you change the value of the first Drop-down list (in G4) all the depending lists are reset to a blank value.

It works great, since the first option of all drop-down lists is a blank cell, so "" value is amongst the allowed choices.   

The thing is that in my case, I´m trying yo implement it to a Table; those drop-down lists are placed in a table (Ctr-T), which means that they propagate downwards as you progress on populating the database table with every new record.  Illustrated in the under picture with the example of the 6th row. 



As I did with the validation formulas, I´m now trying to implement the code against the first row of the table (4th) with the aim it propagates downwards as the table grows, but so far, the reset effect only applyies to the fourth row.

After all I´ve tried, expected resetting to blank, all lists at the same row when changing the first one at the G column, does not happen. It keeps only happening on the first row only, where the code points to.

Macro´s code:


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$4" Then
Range("H4:k4").Value = ""

End If
End Sub


I Tryied with The # simbol to make it understand it is a table, but no success so far.

Thanks a lot.  


Link to the video

Learn how to reset a dependent drop-down list in Excel with a little bit of VBA. The problem we get with dependent data validation lists is that when you cha...
0 Replies