Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to use selected items from Listbox

I use a listbox for making multiple selections, next I want to use this
selection as input for another sub as an array. How do I do that?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to use selected items from Listbox

It is unclear whether you just want to be able to determine which items are
selected or if you actually want to store that information in an array (or if
you want the entire list in an array along with information on which is
selected).
to get the selected items

With userform1.Listbox1
for i = 0 to .listcount - 1
if .selected(i) then
' build array?
msgbox .List(i) & " is selected"
end if
Next
End With

--
Regards,
Tom Ogilvy


" wrote:

I use a listbox for making multiple selections, next I want to use this
selection as input for another sub as an array. How do I do that?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to use selected items from Listbox

Tom,

I want to build an array based on the selected items, and use this
array in another sub.

Regards
Gerard

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to use selected items from Listbox

Sub ABC()
Dim i as Long, v as Variant

With userform1.Listbox1
redim v(0 to .listcount - 1)
j = 0
for i = 0 to .listcount - 1
if .selected(i) then
v(j) = .list(i)
j = j + 1
end if
Next
redim preserve v(0 to j-1)
End With
Mysub v

end sub

Sub Mysub(v as Variant)
for i = lbound(v) to ubound(v)
debug.print i, v(i)
Next
end Sub

--
Regards,
Tom Ogilvy



"Fox_ghk" wrote:

Tom,

I want to build an array based on the selected items, and use this
array in another sub.

Regards
Gerard


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to use selected items from Listbox

Tom,

Many Thanks
I think I can do something nice with it.

Gerard

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
Moving Mutli-Column Multiple-Selected Listbox items up or down MP Excel Discussion (Misc queries) 0 January 14th 09 09:34 PM
ListBox Selected Items into an Array jtp550 Excel Programming 3 September 28th 05 12:44 AM
named range, data validation: list non-selected items, and new added items KR Excel Discussion (Misc queries) 1 June 24th 05 05:21 AM
Adding Items to a ListBox-Unique Items Only jpendegraft[_14_] Excel Programming 2 May 2nd 04 02:27 AM
Items in a Listbox Todd Huttenstine Excel Programming 1 April 26th 04 03:36 PM


All times are GMT +1. The time now is 09:02 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"