Current location - Recipe Complete Network - Complete cookbook - Excel multi-level drop-down menu How to realize that after changing the selection content in the first-level drop-down menu, the content of the second-level drop-down menu is cleared
Excel multi-level drop-down menu How to realize that after changing the selection content in the first-level drop-down menu, the content of the second-level drop-down menu is cleared

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count = 1 And Target.Column = 1 Then

Target.Offset(0, 1 ).Validation.Delete

Target.Offset(0, 1).ClearContents

Select Case Target

Case "Model"

Target.Offset(0, 1).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="1,2,3,4"

Case "ni"

Target.Offset(0, 1).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="5,6,7,8"

Case "ke"

Target.Offset(0, 1).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="9,0,1 ,2"

Case "ta"

Target.Offset(0, 1).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1: ="3,4,5,6"

Case Else

Target.Offset(0, 1) = "Not set"

End Select

p>

End If

End Sub

This first-level menu needs to be set by yourself. I place the first-level menu in column A. When column A is changed, Set a secondary menu for column B. This is the CHANGE event of the worksheet.