|
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
zd = .List(i, 0)
Exit For
End If
Next i
End With
If zd <> "" Then
For i = 2 To UBound(ar)
If ar(i, 2) = zd Then
For j = 2 To 7
Me.Controls("textbox" & j).Text = ar(i, j)
Next j
Exit For
End If
Next i
End If
End Sub
Private Sub TextBox1_Change()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
r = Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "数据源为空!": Exit Sub
ar = Range("a1:g" & r)
Dim br()
ReDim br(1 To UBound(ar), 1 To UBound(ar))
zd = TextBox1.Text
For i = 2 To UBound(ar)
If InStr(ar(i, 2), zd) > 0 Then
d(ar(i, 2)) = ""
n = n + 1
For j = 1 To UBound(ar, 2)
br(n, j) = ar(i, j)
Next j
End If
Next i
x = d.Count
If x = 0 Then MsgBox "没有该关键字的学生姓名!": Exit Sub
If x > 1 Then
ListBox1.Visible = True
ListBox1.List = d.keys
Else
For j = 2 To 7
Me.Controls("textbox" & j).Text = br(1, j)
Next j
End If
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
ListBox1.Visible = False
End Sub
|
评分
-
1
查看全部评分
-
|