Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Works perfect, thanks Rob.
"Rob Bovey" wrote in message ... "Amit Shanker" wrote in message ... Yes, it is indeed a multiselect listbox, with a checkbox shown against each item. If this is expected behaviour, then perhaps you could suggest a solution to my following problem : What I need to do is this : In this multiselect listbox, if no item is checked, then when I click the OK button on the userform, it should simply unload the userform and quit. How do I trap the fact that no check mark is there against any item (so far of course I was trying to use ListIndex = -1)? Hi Amit, In a multi-select listbox you need to loop through each item in the list and check the Selected property of each to determine if any items are selected. Here's an example: Private Sub CommandButton1_Click() Dim bSelected As Boolean Dim lIndex As Long For lIndex = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(lIndex) Then bSelected = True Next lIndex If Not bSelected Then Unload Me ''' Nothing selected. End Sub -- Rob Bovey, Excel MVP Application Professionals http://www.appspro.com/ * Take your Excel development skills to the next level. * Professional Excel Development http://www.appspro.com/Books/Books.htm |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Userform problem (Listindex) | Excel Discussion (Misc queries) | |||
Strange Problem | Excel Discussion (Misc queries) | |||
Strange Problem... | Excel Discussion (Misc queries) | |||
listbox listindex problem | Excel Programming | |||
Strange problem | Excel Programming |