|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Public Myr&, d, k, Arr
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Row < 3 Or Target.Column = 1 Then Exit Sub
If Target.Column > 4 Then Exit Sub
Myr = Sheet2.[a65536].End(xlUp).Row
Arr = Sheet2.Range("a3:z" & Myr)
Set d = CreateObject("Scripting.Dictionary")
If Target <> "" Then
If Target.Column = 2 Then
For i = 1 To UBound(Arr)
If Arr(i, 1) = Target.Value Then
d(Arr(i, 2) & "") = ""
End If
Next i
Target.Offset(0, 1).Select
With Target.Offset(0, 1).Validation
.Delete
.Add Type:=xlValidateList, Formula1:=Join(d.keys, ",")
End With
d.RemoveAll
ElseIf Target.Column = 3 Then
For i = 1 To UBound(Arr)
If Arr(i, 1) = Target.Offset(0, -1).Value And Arr(i, 2) = Target.Value Then
d(Arr(i, 3) & "") = ""
End If
Next i
Target.Offset(0, 1).Select
With Target.Offset(0, 1).Validation
.Delete
.Add Type:=xlValidateList, Formula1:=Join(d.keys, ",")
End With
d.RemoveAll
ElseIf Target.Column = 4 Then
For i = 1 To UBound(Arr)
If Arr(i, 1) = Target.Offset(0, -2).Value And Arr(i, 2) = Target.Offset(0, -1).Value And Arr(i, 3) = Target.Value Then
Target.Offset(0, 1).Value = Arr(i, 4)
Target.Offset(0, 2).Value = Arr(i, 5)
Target.Offset(0, 3).Value = Arr(i, 6)
Target.Offset(0, 4).Value = Arr(i, 7)
Exit For
End If
Next i
End If
End If
End Sub
3级菜单.zip
(13.52 KB, 下载次数: 31)
|
评分
-
1
查看全部评分
-
|