Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default How to disable items in a listbox?

Hi,

I have a multiselect listbox with about 100+ rows, each row can have
one of 4 different application status (ie. 4 types of rows). Ideally
the user should be allowed to select only one type of row. What is
the best way to achieve this?

Is there a way in Excel VBA to selectively disable specific items in a
listbox? Something like greying out the row or removing the option
button for that row will do nicely, i think.

The workaround I use right now is cludgy - I display 2 listboxes - one
for the selectable entries and the other for the all the other type of
rows... Needless to say I am totally unhappy with this approach.

If you have any other solution also (other than using listboxes),
please let know

Thanks in advance for any & all help,
-feltra

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default How to disable items in a listbox?

You cannot disable selected rows, but you can selectively remove items that
are no longer required. The confusion for the user is that the list
suddenly changes and of course if they change their mind the other options
are no longer present. This of course is also true if you could disable
selected rows. 100+ rows is long list for a user to scroll !

You might use option buttons (radio) buttons to select the type then fill
the list with the relevant list. Maybe easy than using two list boxes and
keeps list short.

If you need code let me know.



--

Regards,
Nigel




"feltra" wrote in message
...
Hi,

I have a multiselect listbox with about 100+ rows, each row can have
one of 4 different application status (ie. 4 types of rows). Ideally
the user should be allowed to select only one type of row. What is
the best way to achieve this?

Is there a way in Excel VBA to selectively disable specific items in a
listbox? Something like greying out the row or removing the option
button for that row will do nicely, i think.

The workaround I use right now is cludgy - I display 2 listboxes - one
for the selectable entries and the other for the all the other type of
rows... Needless to say I am totally unhappy with this approach.

If you have any other solution also (other than using listboxes),
please let know

Thanks in advance for any & all help,
-feltra


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default How to disable items in a listbox?

Hi Nigel,

Thanks for replying.

Unfortunately, it will not fill my need. I need to display ALL the
rows, but not allow the user to select the other 3 types of rows (ie.
the user needs to know the status of the other rows). I don't need
the user to be able to decide which items can be selected (that is
decided programatically), so *while* the user is browsing the list and
making up his mind as to which items should be selected, the list
entries will not change (ie. no surprises to user while browsing the
list).

I also wondered but could not implement the following workaround: If
the user clicks on one of the other 3 types (ie one which he should
not be selecting), I will force the option button to become unchecked
and display some status bar message. The reason I could not do it is
because control simply does not come into the Listbox_Click() event
handler, if the selection type is MultiSelect. It comes into the
event handler only for SingleSelect - and I need to have MultiSelect
due to the huge number of rows.


Thanks & Best Regards,
-feltra

On Jan 22, 11:48*pm, "Nigel" wrote:
You cannot disable selected rows, but you can selectively remove items that
are no longer required. *The confusion for the user is that the list
suddenly changes and of course if they change their mind the other options
are no longer present. *This of course is also true if you could disable
selected rows. *100+ rows is long list for a user to scroll !

You might use option buttons (radio) buttons to select the type then fill
the list with the relevant list. Maybe easy than using two list boxes and
keeps list short.

If you need code let me know.

--

Regards,
Nigel


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default How to disable items in a listbox?

Hi,

You could try this. Listbox is populated with content of A1:A26 of the
activesheet.
Create a userform with a list box. You will only be allow to select every
other item.

'-------------------------------
Private m_blnChanging As Boolean
Private Sub ListBox1_Change()
Dim lngIndex As Long

If Not m_blnChanging Then
m_blnChanging = True
For lngIndex = 0 To ListBox1.ListCount - 1
If lngIndex Mod 2 = 0 Then
ListBox1.Selected(lngIndex) = False
End If
Next
m_blnChanging = False
End If

End Sub

Private Sub UserForm_Initialize()

m_blnChanging = True
ListBox1.RowSource = "A1:A26"
ListBox1.MultiSelect = fmMultiSelectMulti
m_blnChanging = False

End Sub
'------------------------
cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"feltra" wrote in message
...
Hi,

I have a multiselect listbox with about 100+ rows, each row can have
one of 4 different application status (ie. 4 types of rows). Ideally
the user should be allowed to select only one type of row. What is
the best way to achieve this?

Is there a way in Excel VBA to selectively disable specific items in a
listbox? Something like greying out the row or removing the option
button for that row will do nicely, i think.

The workaround I use right now is cludgy - I display 2 listboxes - one
for the selectable entries and the other for the all the other type of
rows... Needless to say I am totally unhappy with this approach.

If you have any other solution also (other than using listboxes),
please let know

Thanks in advance for any & all help,
-feltra


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable items on ribbon using VBA Cresta Excel Programming 2 January 21st 09 08:42 AM
disable menu items Josh C Excel Programming 5 May 2nd 07 08:49 PM
Disable Items in Menubar cassy01 Excel Discussion (Misc queries) 2 November 8th 05 08:20 PM
Disable menu items with VBA jst_se Excel Programming 1 July 22nd 04 08:25 PM
Adding Items to a ListBox-Unique Items Only jpendegraft[_14_] Excel Programming 2 May 2nd 04 02:27 AM


All times are GMT +1. The time now is 09:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"