Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default Move all from Listbox1 to Listbox2

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default Move all from Listbox1 to Listbox2

On May 10, 3:08*pm, Matthew Dyer wrote:
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Move all from Listbox1 to Listbox2

Hi

You don't say whether LIstbox2 contains anything that should be kept, so
assuming not:

Private Sub CommandButton1_Click()
Me.ListBox2.List = Me.ListBox1.List
Me.ListBox1.Clear
End Sub

HTH. Best wishes Harald

"Matthew Dyer" wrote in message
...
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!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Move all from Listbox1 to Listbox2

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

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


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
Prevent Coping/Transffering item twice from Listbox1 to Listbox2 K[_2_] Excel Programming 1 November 19th 10 01:35 AM
ListBox2.AddItem ListBox1.Value becomes a String when being Integer? SIGE Excel Programming 2 March 30th 05 04:26 PM
Listbox1 to Listbox2? Moretakitty Excel Programming 16 January 20th 05 10:25 PM
Userform - Populate Listbox2 based on selection in Listbox1 miker1999[_16_] Excel Programming 0 April 29th 04 04:38 AM
(Worksheet)Listbox1.additem = (Form)Listbox1.value ?? Tom Ogilvy Excel Programming 0 September 2nd 03 07:36 PM


All times are GMT +1. The time now is 10:29 PM.

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

About Us

"It's about Microsoft Excel"