ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Transferring data between listboxes (https://www.excelbanter.com/excel-programming/357721-transferring-data-between-listboxes.html)

toocold[_7_]

Transferring data between listboxes
 

Good afternoon,

I have a userform in which I have two listboxes. One is for options
that a user can select from and the other displays the user's
selections. Up to 12 options to choose from. What I want is to
transfer the options selected from the one listbox to the other as the
user selects them. I figured four buttions. Add Selecton, Add All,
Remove Selection, Remove All.

The problem is I am not sure how to get them from one listbox to the
other. And also, how to prevent duplications.

Once again, any help is appreciated!!!
Cheers,
dw


--
toocold
------------------------------------------------------------------------
toocold's Profile: http://www.excelforum.com/member.php...o&userid=31608
View this thread: http://www.excelforum.com/showthread...hreadid=528725


Access101

Transferring data between listboxes
 
Here's kind of a simplified version of what I think you need, cause it sounds
like you know what you're doing other than this, and you could figure out the
rest easily.

Let me know how this works for you.

For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
ListBox2.AddItem ListBox1.List(i)
ListBox1.RemoveItem (i)
End If
Next i


"toocold" wrote:


Good afternoon,

I have a userform in which I have two listboxes. One is for options
that a user can select from and the other displays the user's
selections. Up to 12 options to choose from. What I want is to
transfer the options selected from the one listbox to the other as the
user selects them. I figured four buttions. Add Selecton, Add All,
Remove Selection, Remove All.

The problem is I am not sure how to get them from one listbox to the
other. And also, how to prevent duplications.

Once again, any help is appreciated!!!
Cheers,
dw


--
toocold
------------------------------------------------------------------------
toocold's Profile: http://www.excelforum.com/member.php...o&userid=31608
View this thread: http://www.excelforum.com/showthread...hreadid=528725



toocold[_8_]

Transferring data between listboxes
 

Thanks Access101,

Everything works great except ListBox1.RemoveItem (i). For some
reason, whenever I include this line of code, I get an unspecified
error. I originally tried just coping your code and I got this error.
But if I comment it out, I don't get the error. But I also allow users
to enter the same option twice which is not ideal.

Any idea why this is happening?
Thanks again,
dw


--
toocold
------------------------------------------------------------------------
toocold's Profile: http://www.excelforum.com/member.php...o&userid=31608
View this thread: http://www.excelforum.com/showthread...hreadid=528725


toocold[_9_]

Transferring data between listboxes
 

Still trying to figure this out and I was wondering if maybe my setu
for the listbox is causing me difficulties...

I have populated the listbox from a list in a worksheet. I used th
properties window, and set RowSource = the range for my list. M
question is could having the list populated this way be preventing m
from maniplating the listbox? Is there a better way?

cheers,
d

--
toocol
-----------------------------------------------------------------------
toocold's Profile: http://www.excelforum.com/member.php...fo&userid=3160
View this thread: http://www.excelforum.com/showthread.php?threadid=52872


toocold[_10_]

Transferring data between listboxes
 

Figured it out. By populating the listbox using the UserForm_Initializ
procedure, the code worked perfectly.

Cheers,
d

--
toocol
-----------------------------------------------------------------------
toocold's Profile: http://www.excelforum.com/member.php...fo&userid=3160
View this thread: http://www.excelforum.com/showthread.php?threadid=52872



All times are GMT +1. The time now is 09:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com