This code for a Userform might be adapted for an ActiveX ComboBox. My version does not support ActiveX, but I understand that UF code transfers over almost unchanged.
Dim singleFlag as Boolean
Dim ufEventsDisabled as Boolean
Private Sub ComboBox1_Change()
Dim topVal As Variant
Dim mySStart As Long
If ufEventsDisabled Then Exit Sub
If singleFlag Then singleFlag = False: Exit Sub
With Me.ComboBox1
mySStart = .SelStart
.DropDown
topVal = vbNullString
topVal = Application.Match(.Text, DataList, 1)
If IsNumeric(topVal) Then
.TopIndex = topVal
End If
topVal = Application.Match(.Text & "*", DataList, 0)
If IsNumeric(topVal) Then
.TopIndex = topVal - 1
.ListIndex = topVal - 1
.SelStart = mySStart
.SelLength = Len(.Text) - mySStart
End If
End With
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
singleFlag = (KeyCode = 8)
End Sub
Function DataList() As Variant
Dim xVal As Variant
xVal = Me.ComboBox1.List
DataList = Application.Transpose((Application.Index(xVal, 0, 1)))
End Function
Bookmarks