在 Excel VBA 中使用行值填充 ComboBox
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42017950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Populate ComboBox with Row values in Excel VBA
提问by Rakshith Shetty
I am not able to populate a combobox with cell values stores in a single row, horizontally. It works when they are placed vertically, though.
我无法在单行中水平填充单元格值存储的组合框。但是,当它们垂直放置时它会起作用。
ComboBox.List ("A1:A10") works but ComboBox.List("A1:J1") doesn't. It only displays the first value in the latter case.
ComboBox.List ("A1:A10") 有效,但 ComboBox.List("A1:J1") 无效。在后一种情况下,它只显示第一个值。
I would be grateful if someone could help me out. Thanks :)
如果有人可以帮助我,我将不胜感激。谢谢 :)
采纳答案by A.S.H
Transpose
your array:
Transpose
你的数组:
ComboBox1.List = Application.Transpose(Sheet1.Range("A1:J1").Value)
p.s.: the correct syntax from a column is:
ps:一列的正确语法是:
ComboBox1.List = Sheet1.Range("A1:A10").Value