Reputation: 99
I would Like to use a ComboBox but disable the option to type into it.
I'm trying to populate a textbox from a listbox, using a commandbutton. I can't get the button to transfer whats in the listbox unless the item in the listbox is seleceted and highlighted blue. If I use a combobox it doesn't need to be highlighted, But I don't want the option to type into the box, only select from the list.
This is my entire code that I am testing.
Private Sub CommandButton1_Click()
TextBox1 = Me.ComboBox1.Value
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub UserForm_Initialize()
'Creates and assigns the Array to the ListBox when the form loads.
Dim name As Variant
name = Array("Sunday", "Monday", "Tuesday", "Wednesday", _
"Thursday", "Friday", "Saturday")
ComboBox1.List = name
End Sub
Upvotes: 0
Views: 166
Reputation: 2124
If you change the style when creating the combobox to fmStyleDropDownList this will work.
or
Put this in your code - you will have the name of the combo box below to your objects name (if you have changed it).
Private Sub UserForm_Initialize()
Me.ComboBox1.Style = fmStyleDropDownList
End Sub
Upvotes: 3