|
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If Intersect([c2], Target) Is Nothing Then Exit Sub
- If Target.Rows.Count > 1 Then Exit Sub
- Dim arr, brr, i&, j&, k&, s
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- arr = Range("a2:a" & Range("a15").End(xlUp).Row)
- If Not IsArray(arr) Then Exit Sub
- For i = 1 To UBound(arr)
- If arr(i, 1) <> "" And arr(i, 1) <> 0 Then d(arr(i, 1)) = ""
- Next
- s = Join(d.keys, ",")
- With Target.Validation
- .Delete
- .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=s
- End With
- Set d = Nothing
- End Sub
复制代码 |
|