fill combobox Descending Order

TonySondergeld

New Member
Joined
Jul 11, 2009
Messages
31
Hi All, Just a help required with some code I'm using form this forum and also similar versions found on other site.
Original Post
HTML:
http://www.mrexcel.com/forum/excel-questions/826952-sort-combobox-values-ascending-order-error-code.html
form here

Now the code does work and on a selection with combo-box 1 will place the range into Combo box 2 in the reverse order (Largest to smallest) However this is on a user form which is displayed vbModeless once it finishes the sub sit there and does nothing which stop user from entry to the worksheet and or code running other that selecting combo box 1. The green run button isn't coming back up on visual basic. You can pause it or stop it though. Try put a if option in a couple different place within the code but either it stop in early and doesn't finish the sort or doesn't do anything. Is there a way of getting it to finish the sort and return the worksheet to user control
Code:
Private Sub ComboBox1_Change()
Dim vItems      As Variant
Dim vTemp       As Variant
Dim i           As Long
Dim j           As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
With ComboBox2
.Clear
.List = ws.Range("Product1").Value
End With

vItems = Me.ComboBox2.List
    
    For i = LBound(vItems) To UBound(vItems) - 1
        For j = i + 1 To UBound(vItems)
            If vItems(i, 0) < vItems(j, 0) Then
                vTemp = vItems(i, 0)
                vItems(i, 0) = vItems(j, 0)
                vItems(j, 0) = vTemp
                End If
        Next j
    Next i
    Me.ComboBox2.List = vItems
End Sub
 
Last edited:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,216,028
Messages
6,128,383
Members
449,445
Latest member
JJFabEngineering

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