Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SUMPRODUCT to count items with duplicates where another column contains two defined items PCLIVE Excel Worksheet Functions 4 September 8th 07 10:33 AM
Transferring Information Freddo Excel Worksheet Functions 1 May 5th 06 10:11 PM
order form with multiple items and sizes for items Bernard56 Excel Discussion (Misc queries) 1 January 17th 06 11:43 PM
named range, data validation: list non-selected items, and new added items KR Excel Discussion (Misc queries) 1 June 24th 05 05:21 AM
How do I refresh the selection listboxes on a pivot table? WWW.CS Excel Discussion (Misc queries) 2 February 23rd 05 11:33 AM


All times are GMT +1. The time now is 08:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"