Doflamingo
Board Regular
- Joined
- Apr 16, 2019
- Messages
- 238
Hi all, I try to find the code that would allow me to put the values of a listbox from a userform in one cell of an excel sheet.
Below
Or
But none of those codes work...
Any idea ?
Below
Code:
[FONT=Arial]For b = 0 To ListBox2.ListCount - 1[/FONT]
[FONT=Arial]With Cells(5, 24)[/FONT]
[FONT=Arial] .Value = ListBox2.List(b)[/FONT]
[FONT=Arial]End With[/FONT]
[FONT=Arial]Next[/FONT]
Or
Code:
[FONT=Arial]Dim arrItems()[/FONT]
[FONT=Arial]Dim cnt As Long[/FONT]
[FONT=Arial]Dim I As Long[/FONT]
[FONT=Arial] For I = 0 To ListBox2.ListCount - 1[/FONT]
[FONT=Arial] If ListBox2.Selected(I) Then[/FONT]
[FONT=Arial] ReDim Preserve arrItems(cnt)[/FONT]
[FONT=Arial] arrItems(cnt) = ListBox2.List(I)[/FONT]
[FONT=Arial] cnt = cnt + 1[/FONT]
[FONT=Arial] End If[/FONT]
[FONT=Arial] Next I[/FONT]
[FONT=Arial] If cnt > 0 Then[/FONT]
[FONT=Arial] Cells(5, 24).Value = Join(arrItems, ",")[/FONT]
[FONT=Arial] End If[/FONT]
But none of those codes work...
Any idea ?