tribalKitty
New Member
- Joined
- Jan 11, 2014
- Messages
- 1
I have a listbox with about 15 items with multi-select enabled. I want to copy the selected items to a range in excel. However, if an item is unselected, it should be removed from the range as well.
I will be using these selected items to do a vlookup and set flags.
I have the following snippet, which kind of works. But, it repeatedly copies all the items selected. For eg if item 1 and 2 were selected, then item 3 was selected, it pastes item 1 and 2, then item 1,2, and 3 and so on. I want the selected values to be copied only once to a defined range in excel. What is the best way to do it?
Should I use an array to store the selected items then copy to a range? Will that eliminate the multiple copying of selected items?
Please help.
Also, what is the difference between events "Change" and "Click" of listbox?
Dim is as integer
Dim cur as String
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
cur = ListBox1.List(i)
With Sheets("Sheet1")
.Range("d65536").End(xlUp).Offset(1).Value = cur
End With
End If
Next i
Thank you.
I will be using these selected items to do a vlookup and set flags.
I have the following snippet, which kind of works. But, it repeatedly copies all the items selected. For eg if item 1 and 2 were selected, then item 3 was selected, it pastes item 1 and 2, then item 1,2, and 3 and so on. I want the selected values to be copied only once to a defined range in excel. What is the best way to do it?
Should I use an array to store the selected items then copy to a range? Will that eliminate the multiple copying of selected items?
Please help.
Also, what is the difference between events "Change" and "Click" of listbox?
Dim is as integer
Dim cur as String
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
cur = ListBox1.List(i)
With Sheets("Sheet1")
.Range("d65536").End(xlUp).Offset(1).Value = cur
End With
End If
Next i
Thank you.