Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default listbox with multiple selections

I have built a listbox that allows multiple selections and I have put those
slelections into an array. At this point I want to unload the userform and
use that array in a macro outside of the userform. However, I can't find a
way to access the array I created in the userform. It appears I have to
write the selections to a worksheet, then use a macro to read and write them
into an array and then delete the worksheet in order to move on and do what I
want with an array of selected items. Is that right or am I missing
something?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default listbox with multiple selections

Hi Dave,

Create a button on the Userform.
The code should look something like this:

Cells(2,1).Resize(ubound(YourArray,1),ubound(YourA rray,2)) = YourArray

YourArray should get placed from cell A2 with the above example.
You will - of course - require a bit of error handling here. :)


Regards
Robert McCurdy
"DaveL" wrote in message
...
I have built a listbox that allows multiple selections and I have put those
slelections into an array. At this point I want to unload the userform
and
use that array in a macro outside of the userform. However, I can't find
a
way to access the array I created in the userform. It appears I have to
write the selections to a worksheet, then use a macro to read and write
them
into an array and then delete the worksheet in order to move on and do
what I
want with an array of selected items. Is that right or am I missing
something?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default listbox with multiple selections

Robert,

Thanks for the recommendation. I did what you recommended, but it still
requires taking the selceted items, putting them in a worksheet and then
writing them into another array outside the userform. i was just hoping for
a cleaner more direct route but I guess that's not possible when you are in a
userform.

Dave

"Robert McCurdy" wrote:

Hi Dave,

Create a button on the Userform.
The code should look something like this:

Cells(2,1).Resize(ubound(YourArray,1),ubound(YourA rray,2)) = YourArray

YourArray should get placed from cell A2 with the above example.
You will - of course - require a bit of error handling here. :)


Regards
Robert McCurdy
"DaveL" wrote in message
...
I have built a listbox that allows multiple selections and I have put those
slelections into an array. At this point I want to unload the userform
and
use that array in a macro outside of the userform. However, I can't find
a
way to access the array I created in the userform. It appears I have to
write the selections to a worksheet, then use a macro to read and write
them
into an array and then delete the worksheet in order to move on and do
what I
want with an array of selected items. Is that right or am I missing
something?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default listbox with multiple selections


You need to create a Global Variable in a Standard Module


Code:
--------------------

Public MyArray as variant

--------------------


Set the array in the userform & it willbe available when the form is
closed


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=102032

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default listbox with multiple selections

rouUK,

OK, that made me look foolish. I don't know why I had it in my head that
a variable scoped as public wouldn't work with a userform. This makes it
clean and easy.

"royUK" wrote:


You need to create a Global Variable in a Standard Module


Code:
--------------------

Public MyArray as variant

--------------------


Set the array in the userform & it willbe available when the form is
closed


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=102032




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default listbox with multiple selections


We all make mistakes. Glad it helped

HOW TO GET FURTHER HELP WITH A WORKBOOK
For further help with it why not join our forums (shown in
the link below) it's completely free, if you do join you will have the
opportunity to add attachmnets to your posts so you can add workbooks to
better illustrate your problems and get help directly with them. Also if
you do join please post in this thread (link found below) so that people
who have been following or helping with this query can continue to do
so. :)


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=102032

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
listbox selections [email protected] Excel Programming 1 February 24th 09 02:57 AM
Filter range based on results of multiple selections in a listbox Mctabish[_4_] Excel Programming 0 January 9th 09 07:57 AM
listbox multiple selections Paul Excel Programming 1 February 22nd 08 03:50 PM
Capturing Listbox Selections Randy[_2_] Excel Programming 3 September 14th 07 11:21 PM
How do I retrieve multiple selections from a forms listbox? Wheeler Excel Programming 2 April 21st 05 12:31 AM


All times are GMT +1. The time now is 08:45 PM.

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

About Us

"It's about Microsoft Excel"