|
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With ListBox1
For i = 1 To .ListCount - 1
If .Selected(i) = True Then
zf = .List(i, 0) & "(" & .List(i, 1) & ")"
Exit For
End If
Next i
End With
ActiveCell = zf
End Sub
Private Sub TextBox1_Change()
zd = TextBox1.Text
If zd = "" Then Exit Sub
Dim ar As Variant
Dim arr()
With Sheets("标准试验")
r = .Cells(Rows.Count, 2).End(xlUp).Row
ar = .Range("b2:f" & r)
End With
ReDim arr(1 To UBound(ar), 1 To UBound(ar, 2))
n = 1
For j = 1 To UBound(ar, 2)
arr(n, j) = ar(1, j)
Next j
For i = 2 To UBound(ar)
If InStr(ar(i, 1), zd) > 0 Then
n = n + 1
For j = 1 To UBound(ar, 2)
arr(n, j) = ar(i, j)
Next j
End If
Next i
If n = "" Then Exit Sub
With ListBox1
.Clear
.List = arr
End With
End Sub
Private Sub UserForm_Initialize()
With Sheets("标准试验")
r = .Cells(Rows.Count, 2).End(xlUp).Row
ar = .Range("b2:f" & r)
End With
ListBox1.List = ar
End Sub
|
|