ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Nothing selected in my list box? (https://www.excelbanter.com/excel-programming/420014-nothing-selected-my-list-box.html)

Michelle

Nothing selected in my list box?
 
Hello, I need to find out if the user has selected anything in my
multi-select1 list box, I am currently using

If lbxHeadings.ListIndex = 0 Then

but that is true if nothing is selected or if only the first item is
selected.

If I set option base1 will that allow me to distinguish between nothing
selected and the first item?

Is there an easier way, as option-base1 will mean a rewrite of lots of my
values throughout too?
Thanks

Michelle


Daniel.C[_2_]

Nothing selected in my list box?
 
Hi.
You should use :

With Sheet1.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
'code
End If
Next i
End With

HTH
Daniel

Hello, I need to find out if the user has selected anything in my
multi-select1 list box, I am currently using

If lbxHeadings.ListIndex = 0 Then

but that is true if nothing is selected or if only the first item is
selected.

If I set option base1 will that allow me to distinguish between nothing
selected and the first item?

Is there an easier way, as option-base1 will mean a rewrite of lots of my
values throughout too?
Thanks

Michelle





All times are GMT +1. The time now is 04:11 AM.

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