Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Refer to Multiple List Box Selections 1

Status
Not open for further replies.

TheBlade

MIS
Aug 12, 2001
29
0
0
NZ
Hi

I have a List Box control on my worksheet with 'Multi' selection type, and I would like VB code to return the values selected.

Please note that the control is on the worksheet, not in a user form (I've searched for a solution but the only ones I've seen refer to list boxes on user forms).

Any advice would be greatly appreciated.

Thanks!
Vince
 


Vince,

You have to loop thru each item in the listbox and test for the Selected property

Skip,
[sub]
[glasses] [red]Sign above the facsimile apparatus at the music publisher:[/red]
If it ain't baroque...
Don't FAX it![tongue][/sub]
 
Thanks Skip, unfortunately I am not a VB expert. Can you plse give me a quick example? Perhaps one that takes the results and puts them in adjacent cells?
Thanks
Vince
 

Is this a FORM control or Control Toolbox control?

Skip,
[sub]
[glasses] [red]Sign above the facsimile apparatus at the music publisher:[/red]
If it ain't baroque...
Don't FAX it![tongue][/sub]
 


This is a solution for a FORMS listbox
Code:
    c = 1
    With ActiveSheet.Shapes(1).OLEFormat.Object
        For n = 1 To .ListCount
            If .Selected(n) Then
               ActiveSheet.Shapes(1).TopLeftCell.Offset(0, c).Value = .List(n)
               c = c + 1
            End If
        Next
    End With

Skip,
[sub]
[glasses] [red]Sign above the facsimile apparatus at the music publisher:[/red]
If it ain't baroque...
Don't FAX it![tongue][/sub]
 
Great I can work with that, excellent thanks alot Skip!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top