|
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address(0, 0) = "B8" Then
If Len(Target.Offset(0, -1)) > 0 Then
Set d = CreateObject("scripting.dictionary")
arr = Sheets("B组").UsedRange
For j = 2 To UBound(arr)
If arr(j, 1) = Target.Offset(0, -1) Then d(arr(j, 2)) = ""
Next j
With [B8].Validation
.Delete
If d.Count > 0 Then
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(d.keys, ",")
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End If
End With
End If
End If
End Sub
|
|