ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listbox no selection (https://www.excelbanter.com/excel-programming/423584-listbox-no-selection.html)

John

Listbox no selection
 
How do I tell when no selection has been made when a user has clicked OK on
my UserForm that contains text and list boxes? I get the text box input and
the listbox selections fine, but none of the following tests identify when
the user fails to select anything in the list box.
If IsEmpty(InAIOwner) Then MsgBox "..."
If Len(InAIOwner) = 0Then MsgBox "..."
If InAIOwner = "" Then MsgBox "..."
How do I test for no selection?

I appreciate your help, -John

Harald Staff[_2_]

Listbox no selection
 
Hi John

If nothing is selscted then the ListIndex property is less than zero. Zero
is the first item in the list.

HTH. Best wishes Harald

"John" wrote in message
...
How do I tell when no selection has been made when a user has clicked OK
on
my UserForm that contains text and list boxes? I get the text box input
and
the listbox selections fine, but none of the following tests identify when
the user fails to select anything in the list box.
If IsEmpty(InAIOwner) Then MsgBox "..."
If Len(InAIOwner) = 0Then MsgBox "..."
If InAIOwner = "" Then MsgBox "..."
How do I test for no selection?

I appreciate your help, -John




All times are GMT +1. The time now is 12:23 AM.

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