|
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 2 Or Target.Count > 1 Then Exit Sub
Dim strTemp As String
Dim rgs As Range
Dim rg As Range
strTemp = ""
Set rgs = Sheet2.Range(Sheet2.Cells(2, 1), Sheet2.Cells(65536, 1).End(xlUp))
For Each rg In rgs
If rg = Target Then
strTemp = strTemp & "," & rg.Offset(, 1)
End If
Next
On Error Resume Next
With Target.Offset(, 1).Validation
.Delete
.Add Type:=xlValidateList, Formula1:=Mid(strTemp, 2)
End With
End Sub |
|