|
Dim d As Object
Private Sub Worksheet_Change(ByVal T As Range)
If T.Row > 3 And T.Column = 5 Then
If T.Count > 1 Then End
T.Offset(, 1).Select
With T.Offset(, 1).Validation
.Delete
.Add 3, 1, 1, Join(d(T.Value).keys, ",")
End With
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal T As Range)
If T.Row > 3 And T.Column = 5 Then
If T.Count > 1 Then End
Set d = CreateObject("scripting.dictionary")
With Sheets("考核分值表")
r = .Cells(Rows.Count, 3).End(xlUp).Row
If r < 3 Then MsgBox "考核分值表为空!": End
ar = .Range("a3:d" & r)
End With
For i = 2 To UBound(ar)
If ar(i, 2) = "" Then ar(i, 2) = ar(i - 1, 2)
If ar(i, 2) <> "" Then
If Not d.exists(ar(i, 2)) Then Set d(ar(i, 2)) = CreateObject("scripting.dictionary")
d(ar(i, 2))(ar(i, 3)) = ""
End If
Next i
With T.Validation
.Delete
.Add 3, 1, 1, Join(d.keys, ",")
End With
End If
End Sub
|
|