christianbiker
Active Member
- Joined
- Feb 3, 2006
- Messages
- 365
Hi All,
I have this code that I have pulled from "VBA and Macros for Microsoft Excel" and it works in the context that it is supposed to, however I do have a question.
Private Sub CommandButton1_Click()
Dim lastrow As Long, i As Integer
lastrow = Worksheets("Sheet1").Range("A65536").End(xlUp).Row + 1
Cells(lastrow, 1).Value = TextBox1.Value
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
Cells(lastrow, 2).Value = Cells(lastrow, 2).Value & _
ListBox1.List(i) & ", "
End If
Next i
Cells(lastrow, 3).Value = TextBox2
End Sub
My question is this...
Rather than have all of the selected items placed in one cell, separated by a comma, can I actually have each item placed in it's own separate cell, preferably in list format or horizontally if not?
Thanks!
I have this code that I have pulled from "VBA and Macros for Microsoft Excel" and it works in the context that it is supposed to, however I do have a question.
Private Sub CommandButton1_Click()
Dim lastrow As Long, i As Integer
lastrow = Worksheets("Sheet1").Range("A65536").End(xlUp).Row + 1
Cells(lastrow, 1).Value = TextBox1.Value
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
Cells(lastrow, 2).Value = Cells(lastrow, 2).Value & _
ListBox1.List(i) & ", "
End If
Next i
Cells(lastrow, 3).Value = TextBox2
End Sub
My question is this...
Rather than have all of the selected items placed in one cell, separated by a comma, can I actually have each item placed in it's own separate cell, preferably in list format or horizontally if not?
Thanks!