|
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Dim arr, brr
- If Target.Count > 1 Then Exit Sub
- If Target.Column <> 9 And Target.Column <> 10 Then Exit Sub
- n = [b65536].End(3).Row
- arr = Range("a1:B" & n)
- Set d = CreateObject("scripting.dictionary")
- If Target.Column = 9 Then
- For j = 2 To n
- If arr(j, 1) <> "" Then d(arr(j, 1)) = ""
- Next j
- If Target.Row < 3 Or Target.Row > d.Count + 2 Then Exit Sub
- With Target.Validation
- .Delete
- .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
- Operator:=xlBetween, Formula1:=Join(d.keys, ",")
- End With
- Set d = Nothing
- Target.Offset(0, 1) = ""
- ElseIf Target.Column = 10 And Target.Offset(0, -1) <> "" Then
- Set d = CreateObject("Scripting.Dictionary")
- For i = 2 To UBound(arr)
- If Target.Offset(0, -1) = arr(i, 1) Then
- For k = i To Cells(i, 1).MergeArea.Rows.Count + i - 1
- d(arr(k, 2)) = ""
- Next k
- Exit For
- End If
- Next i
- With Target.Validation
- .Delete
- .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
- Operator:=xlBetween, Formula1:=Join(d.keys, ",")
- End With
- Set d = Nothing
- End If
- End Sub
复制代码
|
评分
-
查看全部评分
|