我想在Excel中使用ActiveX组合框。一切工作正常,从下拉按钮click_event
填充点。但是,当它设置点击事件时,我发现它甚至从诸如箭头键之类的击键中被触发。这是正常的行为,如果是这样,我怎么能绕过这个?Excel ActiveX ComboBox onClick事件
我的工作在Excel 2007中VBA
这是我用来允许使用按键组合框中导航方法,我会等待,看看是否有更好的解决办法..:是的lastKey公共变量
Private Sub ComboBox1_KeyDown(ByVal KeyCode As _
MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then
If ComboBox1.ListIndex <> 0 Then
lastkey = KeyCode
ComboBox1.ListIndex = ComboBox1.ListIndex - 1
KeyCode = 0
End If
ElseIf KeyCode = 40 Then
If ComboBox1.ListIndex <> ComboBox1.ListCount - 1 Then
lastkey = KeyCode
ComboBox1.ListIndex = ComboBox1.ListIndex + 1
KeyCode = 0
End If
End If
End Sub
Private Sub ComboBox1_Click()
If lastkey = 38 Or lastkey = 40 Then
Exit Sub
Else
MsgBox "click"
End If
End Sub
你看到编辑我的帖子? – 2012-08-03 10:35:34
对不起,我认为我错过了它,然后我更新了我的问题 – Deepak 2012-08-04 07:12:08
没有probs :)那么这解决了你的问题? – 2012-08-04 07:28:59