EXCEL VBA中窗口控件复合框内输入内容时能像函数选择时那样输入首字就能显示后边的内容,并验证有效性 50
我想在vba窗体内的物料编码处输入代码32就自动提示32开头的代码,并且内容只能是物料编码存在的编码,如果输入了列表中没有的代码,点确认按钮的时候禁止执行并提示。...
我想在vba窗体内的物料编码处输入代码32 就自动提示32开头的代码 ,并且内容只能是物料编码存在的编码,如果输入了列表中没有的代码,点确认按钮的时候禁止执行并提示。
展开
1个回答
展开全部
Public n As Byte '定义全局变量
Private Sub ComboBox1_Change()
If Me.ComboBox1 = "" Then Me.ComboBox1.List = Array(""): Exit Sub
If n = 38 Or n = 40 Then Exit Sub ‘不响应“向上”及“向下”按键
Dim arr, i&, d As Object
Set d = CreateObject("scripting.dictionary")
arr = [d1].CurrentRegion
For i = 1 To UBound(arr)
If Left(arr(i, 1), Len(Me.ComboBox1)) = Me.ComboBox1 Then d(arr(i, 1)) = arr(i, 1)
Next i
Me.ComboBox1.List = d.keys
Me.ComboBox1.DropDown
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
n = KeyCode
End Sub
Private Sub ComboBox1_Change()
If Me.ComboBox1 = "" Then Me.ComboBox1.List = Array(""): Exit Sub
If n = 38 Or n = 40 Then Exit Sub ‘不响应“向上”及“向下”按键
Dim arr, i&, d As Object
Set d = CreateObject("scripting.dictionary")
arr = [d1].CurrentRegion
For i = 1 To UBound(arr)
If Left(arr(i, 1), Len(Me.ComboBox1)) = Me.ComboBox1 Then d(arr(i, 1)) = arr(i, 1)
Next i
Me.ComboBox1.List = d.keys
Me.ComboBox1.DropDown
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
n = KeyCode
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询