Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiselect Listbox - identify if item picked


Hello

the next conundrum i have in relation to my ongoing userform
development. basically i want to confirm that at least one item has
been selected from my listbox before allowing my commandbutton to
proceed. help!!

(this part i can do) in the event that nothing has been selected i want
to exit sub and prompt user to pick a item from the listbox - so it's
just the first bit that has me stumped. i can't use listindex because
of the multiselect function.

regards
darren


--
apndas
------------------------------------------------------------------------
apndas's Profile: http://www.excelforum.com/member.php...o&userid=36137
View this thread: http://www.excelforum.com/showthread...hreadid=564556

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Multiselect Listbox - identify if item picked

Seems like you have to use the _Change event instead of the _Click events to
detect a click, in Excel2K; seems bizarre as you are clicking without
changing anything.. but anyway.
Private Sub ListBox1_Change()
Dim i As Long
With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
CommandButton1.Enabled = True
Exit Sub
End If
Next
End With
CommandButton1.Enabled = False
End Sub

NickHK

"apndas" wrote in
message ...

Hello

the next conundrum i have in relation to my ongoing userform
development. basically i want to confirm that at least one item has
been selected from my listbox before allowing my commandbutton to
proceed. help!!

(this part i can do) in the event that nothing has been selected i want
to exit sub and prompt user to pick a item from the listbox - so it's
just the first bit that has me stumped. i can't use listindex because
of the multiselect function.

regards
darren


--
apndas
------------------------------------------------------------------------
apndas's Profile:

http://www.excelforum.com/member.php...o&userid=36137
View this thread: http://www.excelforum.com/showthread...hreadid=564556



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiselect Listbox - identify if item picked


Thanks for your reply Nick - that sub works however in disabling the
command button it does not allow me to then select a manifest # and
continue processing my invoice, I just want it to alert me that nothing
has been selected and setfocus on the manifest list and be then able to
select something - that sounds a bit circular - I hope I'm making some
sense.

regards
Darren


--
apndas
------------------------------------------------------------------------
apndas's Profile: http://www.excelforum.com/member.php...o&userid=36137
View this thread: http://www.excelforum.com/showthread...hreadid=564556

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Multiselect Listbox - identify if item picked

You mean something like this ?

Private Sub ListBox1_Change()
Dim i As Long
With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
'Do nothing
Exit Sub
End If
Next
End With
MsgBox "Missing some selection"
ListManifest.SetFocus

End Sub

NickHK


"apndas" ¼¶¼g©ó¶l¥ó·s»D:apndas.2bk3jg_1153923607.6654@excel forum-nospam.com...

Thanks for your reply Nick - that sub works however in disabling the
command button it does not allow me to then select a manifest # and
continue processing my invoice, I just want it to alert me that nothing
has been selected and setfocus on the manifest list and be then able to
select something - that sounds a bit circular - I hope I'm making some
sense.

regards
Darren


--
apndas
------------------------------------------------------------------------
apndas's Profile:
http://www.excelforum.com/member.php...o&userid=36137
View this thread: http://www.excelforum.com/showthread...hreadid=564556



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiselect Listbox - identify if item picked


Hi Nick

Unfortunately that does not work, if I don't select anything in the
listbox (1 or more items) it still processes the invoice when i click
the commandbutton, i think the test needs to be in the
commandbutton_click code, which i also tried but could still not get it
to work???? aagghh!!!


--
apndas
------------------------------------------------------------------------
apndas's Profile: http://www.excelforum.com/member.php...o&userid=36137
View this thread: http://www.excelforum.com/showthread...hreadid=564556



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Multiselect Listbox - identify if item picked

You have the code to test if you have any selection or not, so it's up to
you decide when it is called.

NickHK

"apndas" wrote in
message ...

Hi Nick

Unfortunately that does not work, if I don't select anything in the
listbox (1 or more items) it still processes the invoice when i click
the commandbutton, i think the test needs to be in the
commandbutton_click code, which i also tried but could still not get it
to work???? aagghh!!!


--
apndas
------------------------------------------------------------------------
apndas's Profile:

http://www.excelforum.com/member.php...o&userid=36137
View this thread: http://www.excelforum.com/showthread...hreadid=564556



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
Setting up a list where an item can only be picked once in Excel J. Excel Worksheet Functions 2 May 17th 07 01:17 AM
Multiselect Listbox use RKS Excel Discussion (Misc queries) 1 May 12th 06 03:04 PM
If certain item is picked, then text added... roger_home Excel Discussion (Misc queries) 6 February 12th 06 10:39 PM
Bug in multiselect listbox? Jos Vens[_2_] Excel Programming 2 February 8th 06 08:41 PM
Multiselect Listbox Francis Ang[_3_] Excel Programming 2 October 25th 04 01:57 AM


All times are GMT +1. The time now is 09:56 PM.

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"