View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Listbox use in Excel Listbox use in Excel is offline
external usenet poster
 
Posts: 8
Default How do i find items selected in a list box ?

Hi Tom/Bob:
Thank you both for your patient responses to what might be very elementary
questions. But I am not making progress and somehow there seems to be gaps
in the Excel Help. Here are the details on what I am trying to accomplish:
I have a spreadsheet with the first 10 even numbers in Column A (starting
with 2 in A1 and ending with 20 in A10).
Then I used the "Forms" toolbar to create a Listbox and used the "format
control" to (a) link it to the cells A1:A10 and b) to specify that the
Selection mode is "MULTI".
I am trying to write a Macro to copy three items selected by the user to
Cells A15-A17.
I am getting stuck in (a) referencing the Listbox and then (b) retrieving
the items slected by theuser
Can you help me with the part :
With UserForm1.Listbox1
(which give me the error " Object required")
OR
with Worksheets("Sheet1").Listbox1
which is giving me the error "Object does not support this method or property"

Thanks
manda



"Tom Ogilvy" wrote:

Me refers where the listbox is place

Worksheet
Userform

it is only applicable in a module associated with that location (sheet
module or userform module).

You don't have to use ME. YOu can replace it with a reference to that
location

Worksheets("Sheet1").Combobox1

Userform1.Combobox1

--
Regards,
Tom Ogilvy


"Listbox use in Excel" wrote
in message ...
Hi Bob:
thank you very much for prompt help.
I guess I am still new to this. When I copied your code, I am getting the
error
"Invalid use of Me Keyword" (as a compile error in Visual Basic under

Excel
2003).
I replaced the word Me by ActiveSheet and I am still getting the error.
Is there a way to declare what "Me " is?
thanks
manda

"Bob Phillips" wrote:

With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
Msgbox .List(i)
End If
Next i
End With


--
HTH

Bob Phillips

"Listbox use in Excel"

wrote
in message ...
I created a listbox with "MULTI" option - but the VB help is not

helping
me
write the code to identify the items selected by the user.
This is easy if listbox is "single".

Please help
thanks
manda