ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combobox Exact Match control (https://www.excelbanter.com/excel-programming/427103-combobox-exact-match-control.html)

Bishop

Combobox Exact Match control
 
I have a combobox in a userform that has say 10 list items. When the
userform pops up the combobox is initially empty. I can then enter any of
the 10 list items in the box. The problem is it will also let me choose
nothing... just leave it blank. How can I change it so that one of the 10
list items HAS to be selected so you can't just leave it blank?

Patrick Molloy[_2_]

Combobox Exact Match control
 
you can set the listindex to 0 (zero) which is like selecting the first item
alternatively set the combobox TEXT value to an item in the list

"Bishop" wrote:

I have a combobox in a userform that has say 10 list items. When the
userform pops up the combobox is initially empty. I can then enter any of
the 10 list items in the box. The problem is it will also let me choose
nothing... just leave it blank. How can I change it so that one of the 10
list items HAS to be selected so you can't just leave it blank?


Jacob Skaria

Combobox Exact Match control
 
Add ComboBox1.ListIndex = 0 after adding Items..
--
If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

I have a combobox in a userform that has say 10 list items. When the
userform pops up the combobox is initially empty. I can then enter any of
the 10 list items in the box. The problem is it will also let me choose
nothing... just leave it blank. How can I change it so that one of the 10
list items HAS to be selected so you can't just leave it blank?


Bishop

Combobox Exact Match control
 
I don't have a listindex option under properties. I do have the following
though:

listrows set to 8
liststyle set to 0
listwidth set to 0
tabindex set to 1
topindex set to -1

Should I be looking somewhere else?

"Patrick Molloy" wrote:

you can set the listindex to 0 (zero) which is like selecting the first item
alternatively set the combobox TEXT value to an item in the list

"Bishop" wrote:

I have a combobox in a userform that has say 10 list items. When the
userform pops up the combobox is initially empty. I can then enter any of
the 10 list items in the box. The problem is it will also let me choose
nothing... just leave it blank. How can I change it so that one of the 10
list items HAS to be selected so you can't just leave it blank?


Patrick Molloy[_2_]

Combobox Exact Match control
 
of course yuo do :)

Private Sub UserForm_Initialize()
ComboBox1.AddItem "A"
ComboBox1.AddItem "B"
ComboBox1.ListIndex = 0
End Sub


"Bishop" wrote:

I don't have a listindex option under properties. I do have the following
though:

listrows set to 8
liststyle set to 0
listwidth set to 0
tabindex set to 1
topindex set to -1

Should I be looking somewhere else?

"Patrick Molloy" wrote:

you can set the listindex to 0 (zero) which is like selecting the first item
alternatively set the combobox TEXT value to an item in the list

"Bishop" wrote:

I have a combobox in a userform that has say 10 list items. When the
userform pops up the combobox is initially empty. I can then enter any of
the 10 list items in the box. The problem is it will also let me choose
nothing... just leave it blank. How can I change it so that one of the 10
list items HAS to be selected so you can't just leave it blank?



All times are GMT +1. The time now is 11:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com