Default value of Combobox(form control) VBA

2019-09-08 21:22发布

Hey I have been searching a lot on the internet but I haven't been able to find the solution. I have atleast 10-15 combobox(form control) in my workbook. I want them to display a default value of say "Select type". Now, I have tried doing this using the ".listindex" but then it doesn't allow me to change the value in the combobox(as the default is set permanently).

Can someone help? This is what I tried to use

With ws(1).shapes("Chill1").controlformat
 .listindex = 1
End with

1条回答
老娘就宠你
2楼-- · 2019-09-08 21:24

The default state of the Combobox would be blank, so if anything needs to be put in, it'll usually be an item from the list range.

e.g. the input range (from Properties) is

    A1:A10

and the cell link is

    B1

Then B1 can be manually or through a macro (workbook_open event) set to value: 1

    Private Sub Workbook_Open()
        Worksheets("Sheet1").Range("B1") = 1
    End Sub

and A1 can contain the string 'Select Type'

That way everytime the workbook is opened, the macro sets the 1st values of each of these lists to "Select Type"

查看更多
登录 后发表回答