如何使用命名数组常量填充 Excel 中的 Active-X 组合框
我想将我的 ComboBox 值设置为命名数组常量,您可以在其中进入名称管理器并定义一个名称并为其指定一个值,例如:
={"A", "B", "C"}
我发现 ListFillRange 只会采用一个范围,因此我无法分配对此。
尽管它适用于正常的命名范围,如下所示:
myComboBox.ListFillRange = "MyList"
那么如何分配命名数组常量来填充组合框?
I'd like to setup my ComboBox values as a named array constant, where you go into the Name Manager and define a name and give it a value like:
={"A", "B", "C"}
I've found that ListFillRange will only take a Range so I can't assign to that.
Though it would work for a normal named range, like so:
myComboBox.ListFillRange = "MyList"
So how do you assign a Named Array Constant to fill a ComboBox?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我无法让你的方法为我工作,但这可能是我的设置?
如果我尝试这样做,我会
,或者
2i) 任意假设“J”是列表填充范围
2ii) 定义一个命名范围,例如“COLJ” = =Sheet1!$J$2:INDEX($ J$2:$J$65000,COUNTA($J$2:$J$65000))
2ii) 将所需的项目复制/过滤到 J2:Jx 中
2ii) 使用 VBA 分配 Listfillrange,myComboBox.ListFillRange = "COLJ"
I can't get your method to work for me but it's probably my setup?
If it were me attempting this I would either
or
2i) Assume arbitrarily "J" is the listfill range
2ii) Define a named range, say "COLJ" = =Sheet1!$J$2:INDEX($J$2:$J$65000,COUNTA($J$2:$J$65000))
2ii) Copy/Filter the items you want into J2:Jx
2ii) Assign the Listfillrange using VBA, myComboBox.ListFillRange = "COLJ"
经过大量搜索我找到了这个解决方案:
After much searching I found this solution: