Multiple selections from Listbox into single cell?

sholas

New Member
Joined
Sep 10, 2009
Messages
3
I have a userform in excel that has mutliple selections possible, the issue is I need the selections to go to a single cell in my worksheet. Any help would be much appreciated.

Thank you
Steve
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
try this...
Code:
[/FONT]
[FONT=Courier New]Private Sub CommandButton1_Click()
Dim i As Long
For i = 1 To Me.ListBox1.ListCount - 1
 If Me.ListBox1.Selected(i) Then
  Sheet3.Range("I1").Value = Sheet3.Range("I1").Value & Me.ListBox1.List(i)
 End If
Next i
End Sub
 
Upvote 0
Try like this

Code:
Dim i As Long, s As String
For i = 0 To ListBox1.ListCount - 1
    If ListBox1.Selected(i) Then
        s = s & ListBox1.List(i) & Chr(10)
    End If
Next i
If s <> "" Then Range("A1").Value = Left(s, Len(s) - 1)
 
Upvote 0
Thank you very much for the quick response.
Works great. Have another question, I have two multiple listboxes in my userform and when I add the information to my spreadsheet the data from the first listbox also populates into the second listbox data cell along with that listboxes responds. Again any help would be much appreciated.

Thanks
Steve
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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