Simple Example of a ComboBox in a UserForm with a CommandButton.
All names used are "default" IE: UseForm1, ComboBox1,CommandButton1 etc
This is the "UserForm1" code. Add a ComboBox and a CommandButton then this code to userform.
Private Sub CommandButton1_Click() If ComboBox1.Value = "Win" Then MsgBox "Win" Unload Me ' Close UserForm End If End Sub Private Sub UserForm_Initialize() ' Center UserForm Me.Top = Application.Top + (Application.UsableHeight / 2) - (Me.Height / 2) Me.Left = Application.Left + (Application.UsableWidth / 2) - (Me.Width / 2) ComboBox1.Style = fmStyleDropDownList 'ComboBox.List = Array("Choose a Single File", "Choose Multiple Files") ComboBox1.AddItem "Win", 0 'add item to top of combobox ComboBox1.AddItem "Lose" ' , .ListIndex 'add item to bottom of combobox List Array ComboBox1.AddItem "Tie", 2 'add item to third spot in userform End Sub
Then create a Module with the folliwing and run:
Sub CBUFShow() UserForm1.Show End Sub
Sources:
https://bettersolutions.com/vba/userforms/positioning.htm
https://wellsr.com/vba/2018/excel/how-to-populate-combobox-vba-userforms/
https://stackoverflow.com/questions/7006888/how-to-get-combobox-not-to-accept-user-input-in-excel-vba
https://stackoverflow.com/questions/58887138/open-combobox-in-excel-window/58887261#58887261