|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub Worksheet_Change(ByVal T As Range)
If T.Row = 3 And T.Column = 5 Then
If T.Count > 1 Then End
If T.Value = "" Then End
mykey_1 = Trim(T.Offset(, -1))
mykey_2 = Trim(T.Value)
T.Offset(, 1).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(d(mykey_2).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")
r = Cells(Rows.Count, 2).End(xlUp).Row
ar = Range("b3:c" & r)
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
If Not IsNumeric(ar(i, 1)) Then
If Not d.exists(Trim(ar(i, 1))) Then
Set d(Trim(ar(i, 1))) = CreateObject("scripting.dictionary")
End If
d(Trim(ar(i, 1)))(Trim(ar(i, 2))) = ""
End If
End If
Next i
T.Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(d.keys, ",")
End With
End If
End Sub
|
|