0

Does anybody know how can i fill a listbox from an array? I only know the method with:

With Tabelle1.ListBox1
    .AddItem "Versuch"
End With

i want to make a dynamic listbox but still have no idea.

1
  • 2
    Just use the Listbox's List property, e.g., Tabelle1.ListBox1.List = myArray. Commented Jul 4, 2015 at 19:32

1 Answer 1

4
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
Sign up to request clarification or add additional context in comments.

1 Comment

thank you very much! is it possible to see what ive selected in a multiselection? Ive choosen the array way because i think it is better to recognize which items are selected by a user with array-indexing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.