|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub Worksheet_Change(ByVal Target As Range)
Dim nL%
nL = Target.Column
If Target.Row = 1 Or nL < 5 Or nL > 6 Or Target.CountLarge > 1 Then Exit Sub
Application.EnableEvents = False
Target.Offset(0, 1).Resize(1, 7 - nL).ClearContents
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sj(), nL%, cTxt$, nRow%, Arr(), ds As Object
Set ds = CreateObject("Scripting.Dictionary")
nL = Target.Column - 4
If Target.Row = 1 Or nL < 1 Or nL > 3 Or Target.CountLarge > 1 Then Exit Sub
sj = Range("e" & Target.Row).Resize(1, 2).Value
With Sheets("基础")
nRow = .Cells(99999, nL).End(xlUp).Row
Arr = .Range("a1").Resize(nRow, nL).Value
End With
For i = 2 To nRow
For j = 1 To nL - 1
If Arr(i, j) <> sj(1, j) Then Exit For
Next
If j = nL And Not ds.exists(Arr(i, nL)) Then
ds(Arr(i, nL)) = ""
cTxt = cTxt & "," & Arr(i, nL)
End If
Next
With Target.Validation
.Delete
If cTxt <> "" Then .Add 3, 1, 1, Mid(cTxt, 2)
End With
End Sub
|
评分
-
1
查看全部评分
-
|