How to get the values from MultiSelect listbox?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vaibhav M
    New Member
    • Jan 2011
    • 1

    #1

    How to get the values from MultiSelect listbox?

    Hello, I am new to Excel Macro programming, infact fresher.

    I want to get the multi select values from the list box which has multiple columns.

    For Example;

    User Form List Box shows like below

    Col1 Col2
    1122 John
    1113 Ma

    ry
    1123 Mike

    Upon select of values i,e. 1122 John
    I wany shore that value and show in some ComboBox.

    Can you please help me with the exact Code for the same.

    Thanks inadvance.
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    in the ListBox properties you change SelectionMode to MultiSimple or MultiExtended then when the index is changed (an item selected) you go thru the items selected
    In the following I have a ListBox and a TextBox
    as I select item in the ListBox the items selected are displayed in the textbox
    Code:
        Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
            TextBox1.Text = "Here are the selected items: "
            For Each Item In ListBox1.SelectedItems
                TextBox1.Text &= Item.ToString() & " "
            Next
        End Sub
    using Visual Studio 2008

    Comment

    Working...