我想在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