Excel VBA UserForm Combobox Get Selected Item

Опубликовано: 14 Октябрь 2024
на канале: InAnOffice
26,398
82

Excel VBA UserForm Combobox Learn how to get selected item.

The source code used in this video:

Private Sub cbOK_Click()
If cbDays.ListIndex = -1 Then
MsgBox "Nothing selected"
Else
MsgBox "Selected item: " & cbDays.Value
End If
End Sub

Private Sub UserForm_Initialize()

With cbDays
.AddItem "Monday"
.AddItem "Tuesday"
.AddItem "Wednesday"
End With

End Sub