excel: drop dpwn boxes problem!!

birchy

Newcomer
Joined
Oct 10, 2003
Messages
2
Ok so i know you can do it nut how?:

a drop down box that you can enter data into to search and enter your own data.

mrbirchy_3746115.jpg


please say someone can help.
 
To do the searching bit, you need to code it yourself. Here's a bit of code I wrote to do it (just put this in your keypress event of the combo):
Visual Basic:
If Not (e.KeyChar = ControlChars.Back) And _
    Not (e.KeyChar = ControlChars.Tab) And _
      (cbo.Text.Length > 0) Then

            Dim itemIndex As Integer = -1
            Dim i As New String
            Dim index As Integer = 0

            For Each i In cbo.Items
                If i.ToUpper.StartsWith(cbo.Text.ToUpper) Then
                    itemIndex = index
                    Exit For
                End If
                index += 1
            Next

            If itemIndex > -1 Then
                Dim oldText As String = cbo.Text
                cbo.Text &= cbo.Items(itemIndex).Substring(cbo.Text.Length)
                cbo.SelectionStart = oldText.Length
                cbo.SelectionLength = cbo.Text.Length - oldText.Length
            End If
        End If
You'll obviously need to modify cbo to fit the name of your combo.
 
Back
Top