I have an ActiveX Combobox control on a worksheet and this is the _Change
event code
我在工作表上有一个ActiveX Combobox控件,这是_Change事件代码
Private Sub ComboBox1_Change()
Me.ComboBox1.ListFillRange = "ItemSearch"
Me.ComboBox1.DropDown
End Sub
When I use keyboard up/down key to move through the list it automatically quits Excel.
当我使用键盘上/下键在列表中移动时,它会自动退出Excel。
Does anyone know the solution to this problem? I basically want a dynamic ComboBox.
有谁知道这个问题的解决方案?我基本上想要一个动态的ComboBox。
1 个解决方案
#1
3
You are forcing Combobox's possible values to update when you change the selected option,
that is why it's crashing.
当您更改所选选项时,您正在强制更新Combobox的可能值,这就是崩溃的原因。
You can try to keep Me.ComboBox1.DropDown
in that event.
您可以尝试在该事件中保留Me.ComboBox1.DropDown。
But the .ListFillRange
should be in another event :
但.ListFillRange应该在另一个事件中:
- Workbook_Open
- Workbook_Open
- Workbook_SheetChange
- Workbook_SheetChange
- Worksheet_SelectionChange
- Worksheet_SelectionChange
- Worksheet_Change
- Worksheet_Change
If you're attempting to have a kind of AutoComplete behavior, you can use a built-in property :
如果您尝试使用某种自动完成行为,则可以使用内置属性:
- Right-click on the Control, click on Properties
- 右键单击Control,单击Properties
- In the opened Properties window, find the
MatchEntry
property - 在打开的“属性”窗口中,找到MatchEntry属性
- Set it to
0 - fmMatchEntryFirstLetter
- 将其设置为0 - fmMatchEntryFirstLetter
#1
3
You are forcing Combobox's possible values to update when you change the selected option,
that is why it's crashing.
当您更改所选选项时,您正在强制更新Combobox的可能值,这就是崩溃的原因。
You can try to keep Me.ComboBox1.DropDown
in that event.
您可以尝试在该事件中保留Me.ComboBox1.DropDown。
But the .ListFillRange
should be in another event :
但.ListFillRange应该在另一个事件中:
- Workbook_Open
- Workbook_Open
- Workbook_SheetChange
- Workbook_SheetChange
- Worksheet_SelectionChange
- Worksheet_SelectionChange
- Worksheet_Change
- Worksheet_Change
If you're attempting to have a kind of AutoComplete behavior, you can use a built-in property :
如果您尝试使用某种自动完成行为,则可以使用内置属性:
- Right-click on the Control, click on Properties
- 右键单击Control,单击Properties
- In the opened Properties window, find the
MatchEntry
property - 在打开的“属性”窗口中,找到MatchEntry属性
- Set it to
0 - fmMatchEntryFirstLetter
- 将其设置为0 - fmMatchEntryFirstLetter