MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

2003 - Userform combobox behaviour

  Asked By: Caleb    Date: Aug 12    Category: MS Office    Views: 2120

I was looking at an answer to "filtering drop down list selection" and came
across something interesting.

I have a userform with a listbox and a combobox. I populate the listbox and
use that as a source for populating the combobox.

I've used the code below.

Now when I type numbers into the combobox it behaves as I want... ie the
combobox is filled with just those I'm typing... Before anyone points stuff
out... it's not finished yet :-)

But!! If I've typed 3 numbers in the combobox and then hit backspace the
numbers I want to delete are highlighted!!

Option Explicit
Private Sub cbo1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift
As Integer)

Dim ilN As Integer
Dim slName As String
Dim slListName As String

Select Case KeyCode
Case 65 To 90, 48 To 57
slName = cbo1.Text
cbo1.Text = slName
For ilN = 0 To lst1.ListCount - 1
slListName = lst1.List(ilN)
If InStr(lst1.List(ilN), slName) > 0 Then
cbo1.AddItem slListName
End If
Next ilN
End Select

End Sub
Private Sub UserForm_Initialize()

Dim ilN As Integer

For ilN = 1 To 200
lst1.AddItem CStr(ilN)
Next ilN

End Sub



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on 2003 - Userform combobox behaviour Or get search suggestion and latest updates.