组合框的默认值(表单控件)VBA [英] Default value of Combobox(form control) VBA

查看:388
本文介绍了组合框的默认值(表单控件)VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在互联网上搜索很多,但是我找不到解决方案。我的工作簿中至少有10-15个组合框(窗体控件)。我希望他们显示默认值说选择类型。现在,我已经尝试使用.listindex这样做,但是它不允许我更改组合框中的值(默认设置为永久)。



<有人可以帮忙吗?这是我试图使用的

 用ws(1).shapes(Chill1)。controlformat 
。 listindex = 1
结束


解决方案

默认组合框的状态将为空白,因此如果需要输入任何内容,通常是列表范围中的一个项目。



eg输入范围(属性)为

  A1:A10 

,单元格链接

  B1 

然后B1可以手动或通过宏(workbook_open事件)设置为值:1

  Private Sub Workbook_Open()
工作表(Sheet1)。Range(B1)= 1
End Sub

,A1可以包含字符串选择类型



每当打开工作簿时,宏将这些列表的第一个值设置为选择类型


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

解决方案

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"

这篇关于组合框的默认值(表单控件)VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆