VBA:如何引用组合框对象 [英] VBA: How To Reference ComboBox Object

查看:135
本文介绍了VBA:如何引用组合框对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Excel中的第一个工作表上创建了一个单独的ComboBox。但是,我找不到引用其对象的方法。

I have created a lone ComboBox on the first worksheet in Excel. However, I can't find a way to reference its object.

我插入了一个模块,我的一个子对象可以成功引用以下值:

I inserted a module, and one of my subs can successfully reference the following value:

Sheets( Sheet1)。名称

Sheets("Sheet1").Name

但是,以下内容不可用并引发错误:

However, the following is not available and throws an error:

ComboBox1.Value

ComboBox1.Value

错误消息是:运行时错误'424':需要对象

Error message is: Run-time error '424': Object required

有人可以解释如何引用我的工作表中的这个ComboBox?谢谢

Can someone explain how to reference this ComboBox in my worksheet? Thanks

推荐答案

这取决于您创建的组合框的类型:

That depends on the type of combo box that you created:


  • 表单控制 Sheets( Sheet1)。DropDowns(1)

  • ActiveX控件 Sheets( Sheet1)。ComboBox1

  • Form Control: Sheets("Sheet1").DropDowns(1)
  • ActiveX Control: Sheets("Sheet1").ComboBox1

Sheets( Sheet1)。如果代码位于VBA模块 Sheet1 中,则可以省略。 code>。

Sheets("Sheet1"). can be omitted if the code is placed inside the VBA module Sheet1.

另请参见 Form Controls和 Form Controls之间有什么区别和 ActiveX控件在Excel 2010中?

这篇关于VBA:如何引用组合框对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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