Move all from Listbox1 to Listbox2

M

Matthew Dyer

I have a form with two listboxes. I have a button on the form that,
once pushed, i'd like everything from listbox1 to move to listbox 2.
help? thanks!
 
M

Matthew Dyer

I have a form with two listboxes. I have a button on the form that,
once pushed, i'd like everything from listbox1 to move to listbox 2.
help? thanks!

I figured it out :). For those curious, here is my solution:

Private Sub CommandButton2_Click()
Dim i As Integer
i = 0
Do Until ListBox1.ListCount = 0
ListBox2.AddItem ListBox1.List(i)
ListBox1.RemoveItem i
Loop
End Sub
 
G

GS

Matthew Dyer wrote on 5/10/2011 :
I have a form with two listboxes. I have a button on the form that,
once pushed, i'd like everything from listbox1 to move to listbox 2.
help? thanks!

try...

With Me.ListBox1
ListBox2.List = .List
If .RowSource <> "" Then .RowSource = "" Else .Clear
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top