How to get selected value in multicolumn listbox

后端 未结 4 1725
长发绾君心
长发绾君心 2020-12-06 21:25

I have a multicolumn listbox in my userform and I would like to get all the values of the elements which are in the selected row in the listbox.

Here is my userform:

4条回答
  •  不知归路
    2020-12-06 22:13

    No need to loop the entire list - in order to get the selected item row you can use the ListIndex property. Then you can use the List(Row, Column) property to retreive the data, as in the examples by @DragonSamu and @user3598756:

    '***** Verify that a row is selected first
    If ListBoxResultatFind.ListIndex > -1 And ListBoxResultatFind.Selected(ListBoxResultatFind.ListIndex) Then
        '***** Use the data - in my example only columns 2 & 3 are used
        MsgBox ListBoxResultatFind.List(ListBoxResultatFind.ListIndex, 1) & ":" & ListBoxResultatFind.List(ListBoxResultatFind.ListIndex, 2)
    End If
    

提交回复
热议问题