I am using a combobox(cmbMyName) in userform. Combobox dropdown list source is sorted and unique item is taken using following VBA.
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:
...
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"