Combobox Scrollbar Not Showing up

animas

Active Member
Joined
Sep 28, 2009
Messages
396
I am using a combobox(cmbMyName) in userform. Combobox dropdown list source is sorted and unique item is taken using following VBA.

Code:
...
Combo_UniqueSortList Range("MyRange"), cmbMyName
...
 
Private Sub Combo_UniqueSortList(DataList As Range, cmbName As MSForms.ComboBox)
    Dim Found As Long, i As Long
    Dim cel As Range
 
    ReDim FArray(DataList.Cells.Count)
    i = -1
 
    For Each cel In DataList
        On Error Resume Next
        Found = Application.WorksheetFunction.Match(CStr(cel), FArray, 0)
        If Found > 0 Then GoTo Exists
        i = i + 1
        FArray(i) = cel
Exists:
        Found = 0
    Next
    ReDim Preserve FArray(i)
    Call BubbleSort(FArray)
    cmbName.ListRows = i + 1
    cmbName.List() = FArray
End Sub
 
Sub BubbleSort(MyArray As Variant)
     
    Dim First           As Integer
    Dim Last            As Integer
    Dim i               As Integer
    Dim j               As Integer
    Dim Temp            As String
    Dim List            As String
     
    First = LBound(MyArray)
    Last = UBound(MyArray)
    For i = First To Last - 1
        For j = i + 1 To Last
            If MyArray(i) > MyArray(j) Then
                Temp = MyArray(j)
                MyArray(j) = MyArray(i)
                MyArray(i) = Temp
            End If
        Next j
    Next i
End Sub

Problem is using the above code removes the scrollbar in the combodropdown list.

Instead of using the sort and unique list code of above if i use like below then scroll shows up fine.

What part of the vba code above needs to be changed to make scroll work using the sort n unique functions above?

Code:
'Me.cmbMyName.RowSource = "MyName"
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Remove:
Code:
cmbName.ListRows = i + 1
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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