|
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
ActiveCell = .List(i, 0)
Exit For
End If
Next i
End With
TextBox1.Text = ""
TextBox1.Visible = False
ListBox1.Clear
ListBox1.Visible = False
End Sub
Private Sub TextBox1_Change()
zd = TextBox1.Text
Dim ar As Variant
Dim i As Long, r As Long
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("停线明细")
r = .Cells(Rows.Count, 2).End(xlUp).Row
ar = .Range("c1:c" & r)
End With
For i = 2 To UBound(ar)
If ar(i, 1) <> "" Then
If InStr(ar(i, 1), zd) > 0 Then
d(ar(i, 1)) = ""
End If
End If
Next i
With ListBox1
.Visible = True
.Top = ActiveCell.Top + 15
.Left = ActiveCell.Left + 150
.List = d.keys
.Width = 200
.Height = 400
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal T As Range)
If T.Row > 2 And T.Column = 16 Then
Dim ar As Variant
Dim i As Long, r As Long
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("停线明细")
r = .Cells(Rows.Count, 2).End(xlUp).Row
ar = .Range("c1:c" & r)
End With
For i = 2 To UBound(ar)
If ar(i, 1) <> "" Then
d(ar(i, 1)) = ""
End If
Next i
With TextBox1
.Visible = True
.Top = T.Top
.Left = T.Left
.Activate
End With
With ListBox1
.Visible = True
.Top = ActiveCell.Top + 15
.Left = ActiveCell.Left + 150
.List = d.keys
.Width = 200
.Height = 400
End With
Else
TextBox1.Text = ""
TextBox1.Visible = False
ListBox1.Clear
ListBox1.Visible = False
End If
End Sub
|
|