|
▼名無し さん:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, c As Range
Dim w, v
Set r = Intersect(Target, Columns(3))
If r Is Nothing Then Exit Sub
With Worksheets("従業員名簿")
w = Application.Transpose(.Range("C2", .Cells(Rows.Count, 3).End(xlUp)))
End With
r.Validation.Delete
For Each c In r
If c.Row > 2 Then
If c.Value <> "" Then
v = Filter(w, c.Value)
Application.EnableEvents = False
If UBound(v) = -1 Then
c.ClearContents
ElseIf UBound(v) = 0 Then
c.Value = v
Else
c.Validation.Add Type:=xlValidateList, Formula1:=Join(v, ",")
End If
Application.EnableEvents = True
End If
End If
Next
End Sub
|
|