Select multiple items and paste in cell

jessebraswell

New Member
Joined
Jan 2, 2009
Messages
1
I have a list box, that I have set MultiSelect to "1 - frMultiSelectMulti"
What I would like to be able to do is select multiple items and have those items appear in a single cell on my spreadsheet.
maybe something like: WA, CA, OR
Forms.ListBox.1 is the name of my object. Or do I need to use a different object type?
I would guess I need a little VBA code to make this happen.
Be gentle with me I just do simple VBA code.
Thanks, Jesseb
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
This code is for a userform's list box, it could be adapted to an ActiveX control.
Code:
Dim myString as String
Dim i As Long

With UserForm1.ListBox1
    For i = 0 To .ListCount - 1
        If .Selected(i) Then 
            myString = myString & ", " & .List(i)
        End If
    Next i
End With

Range("A1").Value = Mid(myString, 3)
By the way, why all the selected items in one cell?
If this is for printing only and the user's selection will not be used for further calculation then all in one cell is best. Otherwise each of the selected items in its own cell is better.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,226,730
Messages
6,192,708
Members
453,748
Latest member
akhtarf3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top