|
输入字符实现列表框自己提取数据列: 代码如下, 运行的时候不能达到效果,求高手查看代码! 万分感谢!
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim i%, str$, lg As Boolean
Me.ListBox1.Clear
With Me.TextBox1
For i = 1 To Len(.Value)
If Asc(Mid$(.Value, i, 1)) > 255 Or Asc(Mid$(.Value, i, 1)) < 0 Then
lg = True
str = str & Mid$(.Value, i, 1)
Else
str = str & UCase(Mid$(.Value, i, 1))
End If
Next
End With
With Sheet2
For i = 2 To .Range("a1").End(xlDown).Row
If lg = True Then
If Left$(.Cells(i, 1).Value, Len(str)) = str Then
Me.ListBox1.AddItem .Cells(i, 1).Value
End If
Else
If Left$(.Cells(i, 2).Value, Len(str)) = str Then
Me.ListBox1.AddItem .Cells(i, 1).Value
End If
End If
Next
End With
End Sub
|
|