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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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