ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable item in combobox (https://www.excelbanter.com/excel-programming/286433-disable-item-combobox.html)

Peter Pantus

Disable item in combobox
 
Hi,

Is it possible in a combox to disable one item so the user see the item but
does not can select the item??

Thanks



David Coleman

Disable item in combobox
 
Hi Peter

Out of interest, why do you want to do this? I don't know of a way of doing
this exactly but you could check the chosen value and reject it if it's the
wrong one.

For example, assume combobox1 has three values "Tom", "Dick", "Harry" and
that you don't want the user to be able to choose "Dick"

Private Sub ComboBox1_Change()
If (ComboBox1.Value = "Dick") Then
MsgBox ("Dick is not a valid selection")
ComboBox1.ListIndex = -1
End If
End Sub

This way the user can choose any value (including Dick) buts gets shown a
message when Dick's chosen saying "not valid" and the listindex is set to -1
(i.e. no item chosen)

Hope this helps

David



"Peter Pantus" wrote in message
l...
Hi,

Is it possible in a combox to disable one item so the user see the item

but
does not can select the item??

Thanks





Peter Pantus

Disable item in combobox
 
Thanks David
That is exaclty what I want
It is too complicate too explane why I want to do this


"David Coleman" schreef in bericht
...
Hi Peter

Out of interest, why do you want to do this? I don't know of a way of

doing
this exactly but you could check the chosen value and reject it if it's

the
wrong one.

For example, assume combobox1 has three values "Tom", "Dick", "Harry" and
that you don't want the user to be able to choose "Dick"

Private Sub ComboBox1_Change()
If (ComboBox1.Value = "Dick") Then
MsgBox ("Dick is not a valid selection")
ComboBox1.ListIndex = -1
End If
End Sub

This way the user can choose any value (including Dick) buts gets shown a
message when Dick's chosen saying "not valid" and the listindex is set

to -1
(i.e. no item chosen)

Hope this helps

David



"Peter Pantus" wrote in message
l...
Hi,

Is it possible in a combox to disable one item so the user see the item

but
does not can select the item??

Thanks








All times are GMT +1. The time now is 09:42 AM.

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