ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Test for no listbox selection (https://www.excelbanter.com/excel-programming/423585-test-no-listbox-selection.html)

John

Test for no listbox selection
 
I have a userform w/ a listbox that has a few items. How do I test to be
sure at least one item is selected when OK is clicked. None of the following
will display the MsgBox to find the omision of listbox selection:
If Len(Listbox1) = 0 Then MsgBox "..."
If IsEmpty(Listbox1) Then MsgBox "..."
If Listbox1 = "" Then MsgBox "..."
How do I tell if no selection has been made?

I appreciate your help, -John

Rick Rothstein

Test for no listbox selection
 
The ListIndex property of the ListBox will be -1 (minus one).

--
Rick (MVP - Excel)


"John" wrote in message
...
I have a userform w/ a listbox that has a few items. How do I test to be
sure at least one item is selected when OK is clicked. None of the
following
will display the MsgBox to find the omision of listbox selection:
If Len(Listbox1) = 0 Then MsgBox "..."
If IsEmpty(Listbox1) Then MsgBox "..."
If Listbox1 = "" Then MsgBox "..."
How do I tell if no selection has been made?

I appreciate your help, -John




All times are GMT +1. The time now is 10:55 PM.

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