我正在尝试在表单控件combo box
中默认显示文本选择。我尝试过以下但似乎没有用。有人可以建议我做错了吗?
选项1:
Activesheet.shapes("choose_selection").text = "Select your choice"
选项2:
Activesheet.shapes("choose_selection").controlformat.text = "Select your choice"
但我收到此错误
答案 0 :(得分:0)
在组合框中设置默认值
ListIndex属性使用索引号设置当前选定的项目。 ListIndex = 1设置数组中的第一个值。
Sub ChangeSelectedValue()
With Worksheets("Sheet1").Shapes("Combo Box 1")
.List = Array("select your choice","Apples", "Androids", "Windows")
.ListIndex = 1
End With
End Sub
希望它会有所帮助。
答案 1 :(得分:0)
首先尝试定义DropDown
对象,然后再显示其中的文本。
注意:DropDown
是引用Form_Control ComboBox
的VBA对象。
Dim drpdown As DropDown
' set the drop-down object
Set drpdown = ActiveSheet.DropDowns("choose_selection")
' modify the drop-down properties
With drpdown
.Text = "Select your choice"
End With