View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff[_2_] Harald Staff[_2_] is offline
external usenet poster
 
Posts: 449
Default using variables in listbox

"Other things" is essential here.

My crystal ball has its new year cleaning, so I am at the moment depending
on someone telling me details. If you know someone that can do that, please
post here.

Also, it would help to know what the listbox/userform contains and is meant
to do.

Best wishes Harald

"John" wrote in message
...
Here's my problem. The program runs until "UserForm1.Show" which opens the
listbox and everything works great. I run code similar to what you offered
below and have my data in an array.

But now what? I want to close the listbox and use the data to do other
things. If I do "Unload UserForm1" all the variables are wiped out.

I have a command button "OK" on the userform but the manual I used (Excel
VBA Programming for Dummies) didn't say what to use for it. The only thing
I know is "unload userform1."

Thanks



Harald Staff wrote:
Hi John

Sure. Question is, pass them from the listbox and to what ?

General way to scan the listbox for selections:

Private Sub CommandButton1_Click()
Dim L As Long
For L = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(L) = True Then
MsgBox Me.ListBox1.List(L)
End If
Next
End Sub

HTH. Best wishes Harald


"John" wrote in message
...
My first attempts at using listboxes.

have listbox in a user form with multiple selections.

Is there a way to pass the selections out of the listbox? Right now when
I close the listbox all the variables holding the selections disappear
too.

Or to do more with the selections do I just hide the listbox?

Thanks

JOhn