|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ar, br(), i&, r&
If Target.Count > 1 Then Exit Sub
If Target.Address <> "$D$2" Then Exit Sub
ar = Range("B2", Cells(Rows.Count, "B").End(xlUp)).Value
For i = 1 To UBound(ar)
If Len(ar(i, 1)) Then
If InStr(ar(i, 1), "invalid") = False Then
r = r + 1
ReDim Preserve br(1 To r)
br(r) = ar(i, 1)
End If
End If
Next i
With Target.Validation
.Delete
.Add xlValidateList, xlValidAlertStop, xlEqual, Join(br, ",")
End With
End Sub |
评分
-
1
查看全部评分
-
|