Transfer the entire contents of a listbox to a single worksheet cell.

stirlingmw

Board Regular
Joined
Feb 18, 2013
Messages
75
Afternoon all,

I have been working on a Userform for quite a while now and with your help have it almost ready for use. I am however having trouble transferring multiple rows of data from Listbox to a single cell in a Workbook.
The code I am using at present only transfers the last item in the listbox. I am trying to have all of the items added without having to select each line individually.
The code i am currently using is this:

Code:
totRows = Worksheets("Project Master").Range("A1").CurrentRegion.Rows.count
For i = 2 To totRows
    If Trim(Worksheets("Project Master").Cells(i, 1)) = Trim(CmbFindProject.text) Then 'These lines are also used to add other data to the same worksheet

'this is the code I am using which only adds the last line of data in the list
     For x = 0 To Me.lstILR.ListCount - 1
     Worksheets("Project Master").Cells(i, 52).Value = Me.lstILR.List(x)
     Next x

Exit For
End If
Next i

thanks

Steve
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Replace this...
Code:
     For x = 0 To Me.lstILR.ListCount - 1
     Worksheets("Project Master").Cells(i, 52).Value = Me.lstILR.List(x)
     Next x

With This...
Code:
Worksheets("Project Master").Cells(i, 52).Value = [B]Join(Application.Transpose(Me.ListBox1.List), ", ")[/B]
 
Upvote 0

Forum statistics

Threads
1,223,714
Messages
6,174,044
Members
452,542
Latest member
Bricklin

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