Excel VBA UserForm Listbox Learn how to get selected items.
The source code used in this video:
Private Sub cbOK_Click()
Dim SelectedItems As String
For i = 0 To lbDays.ListCount - 1
If lbDays.Selected(i) = True Then
SelectedItems = SelectedItems & lbDays.List(i) & vbNewLine
End If
Next i
If SelectedItems = "" Then
MsgBox "Nothing selected"
Else
MsgBox "Selected Items: " & vbNewLine & SelectedItems
End If
End Sub
Private Sub UserForm_Initialize()
With lbDays
.AddItem "Monday"
.AddItem "Tuesday"
.AddItem "Wednesday"
End With
End Sub
Watch video Excel VBA UserForm Listbox Get Selected Items online without registration, duration 03 minute 29 second in high hd quality. This video was added by user InAnOffice 03 February 2015, don't forget to share it with your friends and acquaintances, it has been viewed on our site 59 thousand once and liked it 194 people.