Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Transferring items between multicolumn listboxes
Hi-
I've been trying to figure out how to move items between multicolumn listboxes. I have it all expect for one piece. If I select more than one item from the source listbox, I don't get all of the selected items, I only get the first item in the selection repeated a number of times (that number equalling the number of items I originally selected). My code is pasted below. Can anyone steer me in a direction? Thanks ' Variable declarations Dim iIndex Dim iInd2 Dim iSel As Long Dim i As Long Dim x As Long ' Checks to see if there is anything selected ' in the listbox to add If ListBox1.ListIndex = -1 Then GoTo SelectError ' Populates listbox2 With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) Then iIndex = .ListIndex iInd2 = ListBox2.ListCount ListBox2.AddItem .List(iIndex, 0) ListBox2.List(iInd2, 1) = .List(iIndex, 1) ListBox2.List(iInd2, 2) = .List(iIndex, 2) End If Next i End With Exit Sub SelectError: MsgBox "Please make a selection.", vbExclamation + vbOKOnly, "ERROR" |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Transferring items between multicolumn listboxes
You are not using i in yhour code
from: For i = 0 To .ListCount - 1 If .Selected(i) Then iIndex = .ListIndex to: For i = 0 To .ListCount - 1 If .Selected(i) Then iIndex = i " wrote: Hi- I've been trying to figure out how to move items between multicolumn listboxes. I have it all expect for one piece. If I select more than one item from the source listbox, I don't get all of the selected items, I only get the first item in the selection repeated a number of times (that number equalling the number of items I originally selected). My code is pasted below. Can anyone steer me in a direction? Thanks ' Variable declarations Dim iIndex Dim iInd2 Dim iSel As Long Dim i As Long Dim x As Long ' Checks to see if there is anything selected ' in the listbox to add If ListBox1.ListIndex = -1 Then GoTo SelectError ' Populates listbox2 With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) Then iIndex = .ListIndex iInd2 = ListBox2.ListCount ListBox2.AddItem .List(iIndex, 0) ListBox2.List(iInd2, 1) = .List(iIndex, 1) ListBox2.List(iInd2, 2) = .List(iIndex, 2) End If Next i End With Exit Sub SelectError: MsgBox "Please make a selection.", vbExclamation + vbOKOnly, "ERROR" |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Transferring items between multicolumn listboxes
On Sep 28, 9:23 am, Joel wrote:
You are not using i in yhour code from: For i = 0 To .ListCount - 1 If .Selected(i) Then iIndex = .ListIndex to: For i = 0 To .ListCount - 1 If .Selected(i) Then iIndex = i Dude, that's perfect! I knew it had to be something small. I think I was just looking at the code too long... :-) Thanks for your help. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
SUMPRODUCT to count items with duplicates where another column contains two defined items | Excel Worksheet Functions | |||
Transferring Information | Excel Worksheet Functions | |||
order form with multiple items and sizes for items | Excel Discussion (Misc queries) | |||
named range, data validation: list non-selected items, and new added items | Excel Discussion (Misc queries) | |||
How do I refresh the selection listboxes on a pivot table? | Excel Discussion (Misc queries) |