|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.CountLarge <> 1 Then Exit Sub
If Target.Row < 4 Then Exit Sub
Set d = CreateObject("scripting.dictionary")
If Target.Column = 2 Then
arr = Sheets("资料库").UsedRange
For j = 3 To UBound(arr)
d(arr(j, 2)) = ""
Next j
Call youxiao(Target, Join(d.keys, ","))
Else
If Target.Column = 3 Then
If Len(Target.Offset(0, -1)) > 0 Then
arr = Sheets("资料库").UsedRange
For j = 3 To UBound(arr)
If arr(j, 2) = Target.Offset(0, -1) Then d(arr(j, 3)) = ""
Next j
Call youxiao(Target, Join(d.keys, ","))
End If
Else
If Target.Column = 4 Then
str1 = ""
If Len(Target.Offset(0, -1)) > 0 Then
str1 = Target.Offset(0, -1)
Else
For i = Target.Row To 4 Step -1
If Len(Cells(i, 3)) > 0 Then
str1 = Cells(i, 3)
Exit For
End If
Next i
End If
If Len(str1) > 0 Then
arr = Sheets("出入库").UsedRange
For j = 3 To UBound(arr)
If arr(j, 24) = str1 Then d(arr(j, 25)) = ""
Next j
Call youxiao(Target, Join(d.keys, ","))
End If
Else
If Target.Column = 5 Then
If Len(Target.Offset(0, -1)) > 0 Then
For i = Target.Row To 4 Step -1
If Len(Cells(i, 3)) > 0 Then
str1 = Cells(i, 3)
Exit For
End If
Next i
arr = Sheets("出入库").UsedRange
For j = 3 To UBound(arr)
If arr(j, 25) = Target.Offset(0, -1) And arr(j, 24) = str1 Then d(arr(j, 26)) = ""
Next j
Call youxiao(Target, Join(d.keys, ","))
End If
End If
End If
End If
End If
End Sub
Sub youxiao(rng, k)
If Len(k) > 0 Then
With rng.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=k
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With
End If
End Sub
|
评分
-
1
查看全部评分
-
|