|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 chriscole 于 2020-4-15 13:34 编辑
vb的listbox下拉选择菜单,为什么一直会缩小,缩小到连滚动条都没有了,求大神...
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) '/////双击事件
On Error Resume Next '忽略错误值
For x = 0 To yscmhs
If Me.ListBox1.Selected(x) Then
Cells(Selection.Row, 3) = Me.ListBox1.List(x, 0)
Cells(Selection.Row, 4) = Me.ListBox1.List(x, 1) '
Cells(Selection.Row, 5) = Me.ListBox1.List(x, 2)
Cells(Selection.Row, 7) = Me.ListBox1.List(x, 3) '
Cells(Selection.Row, 8) = Me.ListBox1.List(x, 4)
Me.ListBox1.Visible = False '关闭控件
Me.TextBox1.Visible = False
End If
Next
End Sub——————————————————————————————————————————————————————————————————
Private Sub TextBox1_Change()
On Error Resume Next '忽略错误值
With Sheet1
Me.ListBox1.Clear
For x = 2 To .Range("A65300").End(3).Row
If IsNumeric(TextBox1) Then
If .Cells(x, "A") Like "*" & TextBox1 & "*" Then
Me.ListBox1.AddItem
k = k + 1
Me.ListBox1.List(k - 1, 0) = .Cells(x, "A")
Me.ListBox1.List(k - 1, 1) = .Cells(x, "B")
Me.ListBox1.List(k - 1, 2) = .Cells(x, "C")
Me.ListBox1.List(k - 1, 3) = .Cells(x, "E")
Me.ListBox1.List(k - 1, 4) = .Cells(x, "F")
End If
Else
If .Cells(x, "A") Like "*" & UCase(Left(TextBox1, 1)) & "*" Then
Me.ListBox1.AddItem
l = l + 1
Me.ListBox1.List(l - 1, 0) = .Cells(x, "A")
Me.ListBox1.List(l - 1, 1) = .Cells(x, "B")
Me.ListBox1.List(l - 1, 2) = .Cells(x, "C")
Me.ListBox1.List(l - 1, 3) = .Cells(x, "E")
Me.ListBox1.List(l - 1, 4) = .Cells(x, "F")
End If
End If
Next
End With
End Sub
是listbox的问题吗?
|
|