Hi!
A Couple of questions here about VBA codes -
I have a form with multiple dependent drop down lists & require the cells containing these lists to clear each time the parent drop down is changed.
I've managed to do this with 2 parent & dependent lists so far using the below code:
Just to briefly explain;
B16 is my first parent list with C16:G16 containing dependants which then clear when B16 is changed
B18 is my 2nd parent list with C18:F18 & B20:G20 containing dependent lists or formulas which then clear when B18 is changed. My formulas have disappeared though so I'm guessing the below code has cleared them out?
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Column = 2 Then
If Target.Validation.Type = 3 Then
Application.EnableEvents = False
Target.Offset(0, 1).ClearContents
Target.Offset(0, 2).ClearContents
Target.Offset(0, 3).ClearContents
Target.Offset(0, 4).ClearContents
Target.Offset(0, 5).ClearContents
Target.Offset(6, 0).ClearContents
Target.Offset(6, 1).ClearContents
Target.Offset(6, 2).ClearContents
Target.Offset(6, 3).ClearContents
Target.Offset(6, 4).ClearContents
End If
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
End Sub
Private Sub Change(ByVal Target As Range)
On Error Resume Next
If Target.Column = 2 Then
If Target.Validation.Type = 5 Then
Application.EnableEvents = False
Target.Offset(0, 1).ClearContents
Target.Offset(0, 2).ClearContents
Target.Offset(0, 3).ClearContents
Target.Offset(0, 4).ClearContents
Target.Offset(0, 5).ClearContents
End If
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
End Sub
I then want my new parent drop down's C27:C42 to clear out D27:E42 - I'm just not sure how to get multiple codes in the sheet.
It's been a very long time (about 14 years) since I last looked at macro's etc so I'm still quite new to this.
If anyone could give some advice on the codes above & if I could be doing things a different way it would be much appreciated
Bookmarks