Excel VBA:为什么组合框在列表中仅显示一项? [英] Excel VBA: Why does combo box shows only one item in the list?
本文介绍了Excel VBA:为什么组合框在列表中仅显示一项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图通过VBA创建一个组合框,该组合框将在其下拉列表中显示工作表中某些单元格中的多个值.这是相关代码:
I tried to make a combo box via VBA which will show in its drop down list a number of values in certain cells from worksheet. This is the relevant code:
Set header = ActiveWorkbook.Worksheets(source_sheet_1_name).Range(Cells(4, 4), Cells(4, 9))
ActiveWorkbook.Names.Add Name:="header", RefersTo:=header
UserForm2.ComboBox1.RowSource = "header"
但是,组合框仅显示列表中的第一项.我调查了一天,仍然无法弄清楚自己做错了什么.
However, combo box shows only the first item in the list. I looked into it for a day and still could not figure out what I did wrong.
推荐答案
RowSource
不适用于水平列表,但您可以将范围分配给 Column
>组合框的属性,如下所示:
RowSource
won't work with a horizontal list, but you can simply assign the range to the Column
property of the combobox like this:
UserForm2.ComboBox1.Column = Header.Value
这篇关于Excel VBA:为什么组合框在列表中仅显示一项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文