How to get selected value in multicolumn listbox

you can use this code

Private Sub CommandButton3_Click()
    Dim strng As String
    Dim lCol As Long, lRow As Long

    With Me.ListBox1 '<--| refer to your listbox: change "ListBox1" with your actual listbox name
        For lRow = 0 To .ListCount - 1 '<--| loop through listbox rows
            If .selected(lRow) Then '<--| if current row selected
                For lCol = 0 To .ColumnCount - 1 '<--| loop through listbox columns
                    strng = strng & .List(lRow, lCol) & " | " '<--| build your output string
                Next lCol
                MsgBox "you selected" & vbCrLf & Left(strng, (Len(strng) - 1)) '<--| show output string (after removing its last character ("|"))
                Exit For '<-_| exit loop
            End If
        Next lRow
    End With
End Sub

Leave a Comment