Forum Discussion
ehowarth
May 06, 2022Copper Contributor
Concatenate values from a listbox into a cell
Hi Everyone, I have a problem that I have tried every solution I can think of to solve. I have a Listbox that contains multiple contract codes (A029, A031, A032, etc...) that is set to multi-...
HansVogelaar
May 06, 2022MVP
Create a macro in a standard module (the kind you create by selecting Insert > Module in the Visual Basic Editor):
Sub ListValues()
Dim lbx As ListBox
Dim i As Long
Dim s As String
Set lbx = Worksheets("ListBox").ListBoxes(Application.Caller)
For i = 1 To lbx.ListCount
If lbx.Selected(i) Then
s = s & ", " & lbx.List(i)
End If
Next i
If s <> "" Then
s = Mid(s, 3)
End If
Worksheets("Output").Range("C7").Value = s
End Sub
Assign this macro to the list box.