在vba中填充带有数组的列表框

时间:2015-07-04 18:05:42

标签: arrays vba listbox

有人知道如何从listbox填写array吗?我只知道方法:

With Tabelle1.ListBox1
    .AddItem "Versuch"
End With

我想制作dynamic listbox,但仍然不知道。

1 个答案:

答案 0 :(得分:1)

Sub Listbox_Things()

'My Listbox is called "Listbox1" and it is located on "Sheet1"
'With the Listbox visible, F8 through this code

    With Sheet1.ListBox1
        .List = Split("1,2,3", ",")
        .Clear
        .List = Array("One", "Two", "Three")
        .Clear
        .List = Array(1, 2, 3)
        .Clear

        Dim x() As Variant
        x = Array("One", "Two", "Three")

        .List = x
        .Clear
        .List = Application.GetCustomListContents(4)

    End With
End Sub