我写了一个可搜索的组合框。但是,我得到了一个运行时错误'70':不允许。请救救我!
Private Sub cmb_phanloaitheomucdo_12_Change()
Dim i As Long
If Not Comb_Arrow Then
With Me.cmb_phanloaitheomucdo_12
.List = Worksheets("Sheet1").Range(Sheet1.Range("B2"), Worksheets("Sheet1").Cells(Rows.Count, "B").End(xlUp)).Value
.ListRows = Application.WorksheetFunction.Min(4, .ListCount)
.DropDown
If Len(.text) Then
For i = .ListCount - 1 To 0 Step -1
If InStr(1, .List(i), .text, vbTextCompare) = 0 Then .RemoveItem i
Next
.DropDown
End If
End With
End If
End Sub
Private Sub cmb_phanloaitheomucdo_12_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyReturn Then Me.txt_phanloaieau_13.SetFocus
End Sub
1条答案
按热度按时间rmbxnbpk1#
如果组合框控件的
RowSource
属性正在使用中,尝试设置List
属性将触发运行时错误70。若要解决此问题,请在设置
List
属性之前添加一行代码以重置RowSource
属性,或者在VBE中进行必要的调整。