|
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
ActiveCell.Value = .List(i, 0)
ListBox1.Clear
ListBox1.Visible = False
TextBox1 = Empty
TextBox1.Visible = False
Exit For
End If
Next i
End With
End Sub
Private Sub TextBox1_Change()
Dim ar As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
r = Cells(Rows.Count, 1).End(xlUp).Row
ar = Range("a2:b" & r)
zf = TextBox1.Text
For i = 2 To UBound(ar)
If InStr(ar(i, 1), zf) > 0 Then
d(Trim(ar(i, 1))) = ""
mc = ar(i, 1)
End If
Next i
If d.Count = 1 Then
ActiveCell.Value = mc
ListBox1.Clear
ListBox1.Visible = False
TextBox1 = Empty
TextBox1.Visible = False
Else
With ListBox1
.Visible = True
.Top = ActiveCell.Top
.Left = ActiveCell.Left + 50
.Clear
.List = d.keys
End With
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal T As Range)
If T.Row = 3 And T.Column = 5 Then
If T.Count > 1 Then End
With TextBox1
.Visible = True
.Top = T.Top
.Left = T.Left
.Activate
End With
Else
TextBox1 = Empty
TextBox1.Visible = False
ListBox1.Clear
ListBox1.Visible = False
End If
End Sub
|
|