|
楼主 |
发表于 2017-9-26 12:18
|
显示全部楼层
明白了,愿意是应为刚刚是在Private Sub Worksheet_Change(ByVal Target As Range)里。
现在改成
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If Target.Column = 2 Then
- Application.EnableEvents = False
- Dim dic As Object, eic As Object, arr()
- k = Sheet2.Range("a1048576").End(3).Row - 1
- Set eic = CreateObject("Scripting.Dictionary")
- arr = Sheet2.Range("a2").Resize(k, 2)
- For i = 1 To UBound(arr)
- If arr(i, 1) = "类一" Then
- eic(arr(i, 2)) = ""
- End If
- Next
- Sheet1.Range("b" & Target.Row).Validation.Delete
- Sheet1.Range("b" & Target.Row).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=Join(eic.Keys, ",")
- Application.EnableEvents = True
- End If
-
- End Sub
复制代码
这样就可以了,多谢了。 |
|