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

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

问题描述

我在 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.

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

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

Sheets("Sheet1"). 如果代码放在 VBA 模块 Sheet1 中,则可以省略.

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

另见什么是表单控件"和表单控件"之间的区别.和ActiveX 控件"在 Excel 2010 中?

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

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