Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim lngItem As Long
- Const strSep = ", " 'delimiter
- Private Sub UserForm_Initialize()
- With ListBox1
- .RowSource = "=Sheet1!A2:A12"
- For lngItem = 0 To ListBox1.ListCount - 1
- .Selected(lngItem) = InStr(1, strSep & ActiveCell.Value & strSep, strSep & .List(lngItem, 0) & strSep)
- Next lngItem
- End With
- End Sub
- Private Sub CommandButton1_Click()
- Dim strItems As String
- With ListBox1
- For lngItem = 0 To ListBox1.ListCount - 1
- If ListBox1.Selected(lngItem) Then
- strItems = strItems & strSep & ListBox1.List(lngItem, 0)
- End If
- Next lngItem
- End With
- With ActiveCell
- .NumberFormat = "@"
- .Value = Replace(strItems, strSep, "", 1, 1)
- End With
- Unload Me
- End Sub
- Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
- If Target.Column <> 3 Or Target.Row = 1 Then Exit Sub
- UserForm1.Show
- Cancel = True
- End Sub
Add Comment
Please, Sign In to add comment