|
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
ActiveCell.Offset(, 0) = .List(i, 1)
ActiveCell.Offset(, 1) = .List(i, 2)
ActiveCell.Offset(, 2) = .List(i, 3)
Exit For
End If
Next i
.Visible = False
TextBox1.Visible = False
End With
End Sub
Private Sub TextBox1_Change()
ar = Sheets("数据库").[a1].CurrentRegion
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
For i = 3 To UBound(ar)
If InStr(ar(i, 2), TextBox1.Text) > 0 Then
n = n + 1
For j = 1 To UBound(ar, 2)
br(n, j) = ar(i, j)
Next j
End If
Next i
If n = "" Then Exit Sub
With ListBox1
.Visible = True
.Top = ActiveCell.Top + 30
.Left = ActiveCell.Left + 100
.List = br
End With
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal T As Range, Cancel As Boolean)
If T.Row > 6 And T.Row < 16 And T.Column = 2 Then
With TextBox1
.Visible = True
.Top = T.Top
.Left = T.Left
.Activate
End With
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal T As Range)
If T.Row < 6 Or T.Row > 16 Then
TextBox1 = ""
TextBox1.Visible = False
ListBox1.Visible = False
End If
End Sub
|
|