gpt4 book ai didi

excel - VBA:如何引用组合框对象

转载 作者:行者123 更新时间:2023-12-02 16:05:35 25 4
gpt4 key购买 nike

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

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

工作表(“Sheet1”).名称

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

ComboBox1.Value

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

有人可以解释如何在我的工作表中引用此组合框吗?谢谢

最佳答案

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

  • 表单控件:Sheets("Sheet1").DropDowns(1)
  • ActiveX 控件:Sheets("Sheet1").ComboBox1
如果代码放置在 VBA 模块 Sheet1 内部,则可以省略

Sheets("Sheet1").

另请参阅What is the difference between "Form Controls" and "ActiveX Control" in Excel 2010?

关于excel - VBA:如何引用组合框对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44083621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com