“撤消”comboboxDropButtonClick
我有一系列ComboBoxes
是基于前面的ComboBox
select填充的。 因此,例如, ComboBox3
基于在ComboBox2
select的值填充。 填充ComboBox3
的“触发器”是DropButtonClick
操作。 当ComboBox2中没有值时,popup一个消息框。 这是成功的工作 – 代码如下。
If Me.ComboBox2.ListIndex = -1 Then MsgBox "Please select all preceding comboboxes" ComboBox3.Value = "" Exit Sub Else sh.Range("B2") = Me.ComboBox2.Value End If
我的问题是一旦Message Box
出现(由于ComboBox2
中没有值) ComboBox3
仍然显示下拉值。 有没有办法在ComboBox3 DropButtonClick Event
中没有值时撤消ComboBox3 DropButtonClick Event
,以便ComboBox3
永远不会下降?
您可以通过模拟“ESC”键立即closurescombobox的下拉窗口:
MsgBox "Please select all preceding comboboxes" ComboBox3.Value = "" ' close immediately the combo's dropdown window SendKeys "{ESC}{ESC}"
这是给你的东西吗?
If Me.ComboBox2.Value = "" Then ComboBox2.SetFocus Else sh.Range("B2") = Me.ComboBox2.Value End If
当你想单击combobox3的dropbutton时,它会自动返回到combobox2。