Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Exiting listboxes in a userform

I have created a userform in Excel which contains a listbox to which the user
can make multi selections.

Is it possible to include some code that will when the user exits the form
will only show the elements of the userform that have been selected and will
hide the elements that have not been selected.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Exiting listboxes in a userform

You didn't say where you wanted to "show" the selected items at when the
UserForm is closed. Here is code that puts the selected items into an array
in code... you can use that to see how to read the selected items (the
For..Next loop is the key to that) and then put them wherever it is you
wanted them to go...

Dim X As Long
Dim Index As Long
Dim SelectedItems() As String
With Me.ListBox1
ReDim SelectedItems(0 To .ListCount)
For X = 0 To .ListCount - 1
If .Selected(X) Then
SelectedItems(Index) = .List(X)
Index = Index + 1
End If
Next
ReDim Preserve SelectedItems(0 To Index - 1)
End With

--
Rick (MVP - Excel)


"nir020" wrote in message
...
I have created a userform in Excel which contains a listbox to which the
user
can make multi selections.

Is it possible to include some code that will when the user exits the form
will only show the elements of the userform that have been selected and
will
hide the elements that have not been selected.

Thanks


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
Exiting a procedure with a userform jumpjump[_4_] Excel Programming 2 August 30th 05 09:04 AM
Userform with 2 Listboxes Mike R. Excel Programming 2 February 12th 05 07:21 AM
Userform w/ Multiple listboxes that link miker1999[_13_] Excel Programming 1 April 27th 04 03:22 AM
Userform w/ Multiple listboxes that link miker1999[_12_] Excel Programming 0 April 20th 04 12:35 PM
Userform and reading multiple listboxes Bijl167[_6_] Excel Programming 3 December 8th 03 01:40 PM


All times are GMT +1. The time now is 09:07 AM.

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"