简体   繁体   中英

Deleting a dynamic dropdown in excel using vba

I am populating a dynamic dropdown in excel. When my value is Digital I populate some values in adjacent cell and when it is other value it should delete that dropdown and disable the cell.

Can someone help me in this?

What about this?

 Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address Like "*A*" And Target.Cells.Count = 1 Then

        If Application.WorksheetFunction.IsNumber(Target.Value) Then
            With Target.Offset(0, 1)
                .Validation.Add Type:=xlValidateList, Formula1:="Item1, Item2"
                .Value = "Item1"
                .Locked = False
            End With
        Else
            With Target.Offset(0, 1)
                .Validation.Delete
                .Value = ""
                .Locked = True
            End With
        End If
    End If

    End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM