View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
BigPig BigPig is offline
external usenet poster
 
Posts: 77
Default Multiselect listbox if no selection

Hi All,

I have a listbox that is multiselect. I want to find a way to figure out if
anything is selected, if not "do something". I wrote this which works, but I
have to think that there is an easier way.

Dim Z As Integer
Z = 0
With lst_Comp_Lv
For i = 0 To .ListCount - 1
If .Selected(i) Then
Else
Z = Z + 1
End If
Next i
End With

If Z = lst_Comp_Lv.ListCount Then
MsgBox "There was nothing selected."
Exit Sub
End If

I also tried:

If lst_Comp_Lv = Null Then
MsgBox "There is nothing selected."
Exit Sub
End If

But that didn't work.

Any suggestions or advice you could provide would be greatly appreciated.
Thank you.