Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel Can';t在userform中向listbox添加两列_Excel_Listbox_Vba - Fatal编程技术网

Excel Can';t在userform中向listbox添加两列

Excel Can';t在userform中向listbox添加两列,excel,listbox,vba,Excel,Listbox,Vba,我有两列要添加到列表框中。第一列是常规数字,第二列是时间格式的数字。当我单独选择一列时,它会显示在列表框中。问题是,当我同时选择它们时,只会添加第一个 我使用了多个列表框,每次迭代的范围都会改变 我编写的填充列表框的代码如下: With Controls("Listbox" & k + 1) .RowSource = "Sheet1!" & Range(Cells(2, i), Cells(97, i + 1)).Address End With 可能发生什么情

我有两列要添加到列表框中。第一列是常规数字,第二列是时间格式的数字。当我单独选择一列时,它会显示在列表框中。问题是,当我同时选择它们时,只会添加第一个

我使用了多个列表框,每次迭代的范围都会改变

我编写的填充列表框的代码如下:

With Controls("Listbox" & k + 1)
        .RowSource = "Sheet1!" & Range(Cells(2, i), Cells(97, i + 1)).Address
End With

可能发生什么情况?

您是否将
ColumnCount
属性设置为2(使用代码或
列表框
属性)

例如:

With Me.ListBox1
    .ColumnCount = 2
    .RowSource = "Sheet1!A1:B10"
End With

我不知道我必须设置
ColumnCount
属性。现在它工作了!非常感谢。