|
Private Sub ListBox1_Change()
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
If InStr(zd, ListBox1.List(i, 0)) = 0 Then
If zd = "" Then
zd = ListBox1.List(i, 0)
Else
zd = zd & Chr(10) & ListBox1.List(i, 0)
End If
End If
End If
Next i
ActiveCell = zd
End Sub
Private Sub Worksheet_SelectionChange(ByVal T As Range)
If T.Row = 9 And T.Column = 2 Then
Dim ar As Variant
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("数据源")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:e" & r)
End With
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) <> "" Then
d(Trim(ar(i, 2))) = ""
End If
Next i
With ListBox1
.Visible = True
.List = d.keys
End With
Else
ListBox1.Visible = False
End If
End Sub
|
|