sort ListBox2 multicolumn upside down

al.extreme

New Member
Joined
Nov 29, 2010
Messages
15
Hi

I have listbox1 MultiSelectExtended (2 columns). If the items are selected I add them to listbox2 (also in 2 columns) with a CommandButton. The problem is that the code I have in the CommandButton adds them upside down!

I want to transfer from listbox1 to listbox 2 in the same order as listbox1 (Top to Bottom)
Can someone help me ?
Thanks

This is the code:

With ListBox1
For eCount = .ListCount - 1 To 0 Step -1
If .Selected(eCount) = True Then ' if selected then
ListBox2.AddItem .List(eCount, 0) 'add to listbox2, Column 0
ListBox2.Column(1, ListBox2.ListCount - 1) = .List(eCount, 1) 'add to listbox2, Column 1
End If
Next
End With
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi Mike

instead of:
For eCount = .ListCount - 1 To 0 Step -1

I used:
For eCount = .ListCount - 1 To 0 Step 1

but I didn't work.

I also tried after "end if"

eCount = eCount +1
but it just collapsed excel :(

any hint ?
 
Upvote 0

Forum statistics

Threads
1,223,627
Messages
6,173,424
Members
452,515
Latest member
Alicedonald9

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