|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
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)
TextBox1.Visible = False
TextBox1 = ""
Exit For
End If
Next i
.Visible = False
.Clear
End With
End Sub
Private Sub TextBox1_Change()
Dim ar As Variant
Dim br()
With Sheet2
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:a" & r)
End With
ReDim br(1 To UBound(ar), 1 To 1)
zd = TextBox1.Text
For i = 21 To UBound(ar)
If InStr(ar(i, 1), zd) > 0 Then
n = n + 1
br(n, 1) = ar(i, 1)
End If
Next i
With ListBox1
.Visible = True
.Top = ActiveCell.Top + 20
.Left = ActiveCell.Left
.List = br
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal T As Range)
If T.Row > 1 And T.Column = 1 Then
If T.Count > 1 Then End
With TextBox1
.Visible = True
.Top = T.Top
.Left = T.Left
.Activate
End With
Else
TextBox1.Visible = False
TextBox1 = ""
End If
End Sub
|
|