Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Listbox none selected feature

It seems that there is no property for determining if a listbox
(multiselect) has at least one selection. Browsing this board I find the
common method below for accomplishing the task, but was surprised that no
property exists. Is it true?

For i = 0 to .listcount - 1
If .selected(i) = true then
'do something'
End if
Next i

Mike


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Listbox none selected feature

I have used this code before to determine if there is a selection:

If Me.lstManager.ListIndex = -1 Then
MsgBox "You don't have a Manager selected, please make a
selection and try again.", _
vbExclamation, "Make a Selection"
End If

This doesn't count the number of selections, but does detect if there
is a selection.

You can also use this:

If Me.lstManager.Selected = True then
'Do this code
End if

If selected = true, at least one value is selected. Likewise, if
selected = false, no selections have been made. This however only
applies to list boxes with multiselect = true.

Hope that helps

theSquirrel



On Dec 12, 10:25 am, "Mike Milligan" wrote:
It seems that there is no property for determining if a listbox
(multiselect) has at least one selection. Browsing this board I find the
common method below for accomplishing the task, but was surprised that no
property exists. Is it true?

For i = 0 to .listcount - 1
If .selected(i) = true then
'do something'
End if
Next i

Mike


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Listbox none selected feature

I thought of listindex, but ListIndex cannot be used with a 'multiselect'
listbox, which I have.

Thanks anyway.
Mike

wrote in message
ups.com...
I have used this code before to determine if there is a selection:

If Me.lstManager.ListIndex = -1 Then
MsgBox "You don't have a Manager selected, please make a
selection and try again.", _
vbExclamation, "Make a Selection"
End If

This doesn't count the number of selections, but does detect if there
is a selection.

You can also use this:

If Me.lstManager.Selected = True then
'Do this code
End if

If selected = true, at least one value is selected. Likewise, if
selected = false, no selections have been made. This however only
applies to list boxes with multiselect = true.

Hope that helps

theSquirrel



On Dec 12, 10:25 am, "Mike Milligan" wrote:
It seems that there is no property for determining if a listbox
(multiselect) has at least one selection. Browsing this board I find the
common method below for accomplishing the task, but was surprised that no
property exists. Is it true?

For i = 0 to .listcount - 1
If .selected(i) = true then
'do something'
End if
Next i

Mike




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Listbox none selected feature

The second part of my post listed this code as well...

You can also use this:

If Me.lstManager.Selected = True then
'Do this code
End if

This will be true if there is a selection, and false if there is no
selection.

theSquirrel

On Dec 12, 1:11 pm, "Mike Milligan" wrote:
I thought of listindex, but ListIndex cannot be used with a 'multiselect'
listbox, which I have.

Thanks anyway.
Mike

wrote in oglegroups.com...



I have used this code before to determine if there is a selection:


If Me.lstManager.ListIndex = -1 Then
MsgBox "You don't have a Manager selected, please make a
selection and try again.", _
vbExclamation, "Make a Selection"
End If


This doesn't count the number of selections, but does detect if there
is a selection.


You can also use this:


If Me.lstManager.Selected = True then
'Do this code
End if


If selected = true, at least one value is selected. Likewise, if
selected = false, no selections have been made. This however only
applies to list boxes with multiselect = true.


Hope that helps


theSquirrel


On Dec 12, 10:25 am, "Mike Milligan" wrote:
It seems that there is no property for determining if a listbox
(multiselect) has at least one selection. Browsing this board I find the
common method below for accomplishing the task, but was surprised that no
property exists. Is it true?


For i = 0 to .listcount - 1
If .selected(i) = true then
'do something'
End if
Next i


Mike- Hide quoted text -- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Listbox none selected feature

I receive an "argument not optional" error highlighting '.Selected' as the
offending property.



wrote in message
ups.com...
The second part of my post listed this code as well...

You can also use this:

If Me.lstManager.Selected = True then
'Do this code
End if

This will be true if there is a selection, and false if there is no
selection.

theSquirrel

On Dec 12, 1:11 pm, "Mike Milligan" wrote:
I thought of listindex, but ListIndex cannot be used with a 'multiselect'
listbox, which I have.

Thanks anyway.
Mike

wrote in
oglegroups.com...



I have used this code before to determine if there is a selection:


If Me.lstManager.ListIndex = -1 Then
MsgBox "You don't have a Manager selected, please make a
selection and try again.", _
vbExclamation, "Make a Selection"
End If


This doesn't count the number of selections, but does detect if there
is a selection.


You can also use this:


If Me.lstManager.Selected = True then
'Do this code
End if


If selected = true, at least one value is selected. Likewise, if
selected = false, no selections have been made. This however only
applies to list boxes with multiselect = true.


Hope that helps


theSquirrel


On Dec 12, 10:25 am, "Mike Milligan" wrote:
It seems that there is no property for determining if a listbox
(multiselect) has at least one selection. Browsing this board I find
the
common method below for accomplishing the task, but was surprised that
no
property exists. Is it true?


For i = 0 to .listcount - 1
If .selected(i) = true then
'do something'
End if
Next i


Mike- Hide quoted text -- Show quoted text -




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use selected items from Listbox [email protected] Excel Programming 4 April 7th 06 04:02 PM
getting selected listbox values x taol Excel Programming 1 January 27th 06 12:39 AM
How to add selected row into listbox? frankosun Excel Programming 1 December 17th 05 10:01 PM
ListBox Selected Items into an Array jtp550 Excel Programming 3 September 28th 05 12:44 AM
Transposing a rng selected from a listbox JoeH[_7_] Excel Programming 4 September 12th 04 03:26 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"