combobox, 2 listbox's and a text box

technix

Active Member
Joined
May 19, 2002
Messages
326
I have a Userform with a listbox that I would like to populate using a textbox on the same form, the combo box is on a different userform and needs to be populated by the items in the listbox. On my userform with the 2 listbox's and the textbox the 2nd listbox is to be populated by selecting items in the first listbox and then pressing a command button however if they select the items in listbox 2 and press a command button it places the selections back in listbox 1 and removes the from listbox 2.

Now that I have painted the picture could you help me with what items in the help should I look up to accomplish this task.

If you need need a screen shot of the form to get the picture or need more help please do not hesitate to ask me.

Derrick
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
On 2002-08-28 16:51, Juan Pablo G. wrote:
Derrick, I don't follow. Can you explain a little more ? maybe use some examples ?

Ok I will try to be a little clearer, I have a userform it has two listboxes, in between the list boxes are to buttons one has an arrow that goes like this «« and the other goes like this »».
It also has a textbox, the textbox has a caption to Enter saleperson name, then there is a command button when clicked I need to have it add the value of the textbox to listbox 1 etc, then when listbox 1 has multpile selections and they hit the command button »» it will move them items to listbox2. if they select an item in listbox2 and hit «« it puts them back in listbox 1. In addition, the items in listbox1 populate the combobox on a different userform, if it will help I can send the workbook via email. I am not looking for 100% completion of what i need here, just maybe a little head start and exactly what I need to look in in order to learn it

Thanks

Derrick
 
Upvote 0
I appologize for keep bringing this to the front of the list, however, I really need to learn how to do this and havent really figured this out.

Derrick
 
Upvote 0
Ok I have figured out step 1, I am now able to type something in the textbox and hit the command button and have that textbox value added to listbox1, listbox 1 has multiselect enabled, now my dilema is how do I get my multiselected values in listbox1 to move to listbox2 when I click the commandbutton, I have tried the following and to no go

Code:
Private Sub CommandButton1_Click()
ListBox2.AddItem (ListBox1.Value)
ListBox1.Value = Empty
End Sub

Thank you for any additional help, again if you could point me in the direction to look so that I may learn

Derrick
 
Upvote 0
using the following code I am able to accomplish a step closer to what I am trying to do with listbox - listbox

Code:
Private Sub »»_Click()
ListBox2.AddItem (ListBox1.ListIndex)
ListBox1.SetFocus

    'Ensure ListBox contains list items
    If ListBox1.ListCount >= 1 Then
             
        ListBox1.RemoveItem (ListBox1.ListIndex)
End If


End Sub

However, instead of placing the selected text from the listbox1 it places the number value of 0- whatever, Also it will only move the last selected out of the multiselect and remove the last selected rather than all selected. How do I get it to move all values selected and return the text from listbox1 to listbox2 ?

Derrick


_________________
Http://www.cashglow.com/affiliates/technix
This message was edited by technix on 2002-08-30 16:38
 
Upvote 0
Ok people im slowly making progress however i am getting frustrated and ask please help

I now have it able to move the text using the following

Code:
Private Sub »»_Click()
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
ListBox2.AddItem (ListBox1.List(i))
End If
Next i

ListBox1.SetFocus

    'Ensure ListBox contains list items
    If ListBox1.ListCount >= 1 Then
             
        ListBox1.RemoveItem (ListBox1.ListIndex)
End If


End Sub

the problem with this is if i select more than one item it only removes the last item selected from listbox1 once it is placed in the listbox2

Derrick
 
Upvote 0
With the help of Ivan I have now finished getting my listbox1 and listbox2 setup to where I can multiselect the items and move then between listbox's and delete the selections from the box after moved, Now I need help doing the following, I would like the list of items in listbox1 to be placed in a worksheet so that I may use the sheet to access teh list in a combobox What would I need to do in order to make this happen

Derrick
 
Upvote 0
On 2002-08-31 00:17, technix wrote:
With the help of Ivan I have now finished getting my listbox1 and listbox2 setup to where I can multiselect the items and move then between listbox's and delete the selections from the box after moved, Now I need help doing the following, I would like the list of items in listbox1 to be placed in a worksheet so that I may use the sheet to access teh list in a combobox What would I need to do in order to make this happen

Derrick

Derrick, how are you adding the items to the listbox?
If a load time then you should also load the combobox the same...ussing the sam method = Additem
 
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top