Search with special letter on combobox dropdown list

maabadi

Well-known Member
Joined
Oct 22, 2012
Messages
2,681
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi
I want when I don't now exact name, and type for example "b*0" then show result by
"b20, b-20, b-120, b-30 cms-c and ..."

thanks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
May be
Code:
Private Sub ComboBox1_Change()    Dim i As Long
    With Me.ComboBox1
        If Not IsArrow Then .List = Range("A1:A1000").Value
        If .ListIndex = -1 And Len(.Text) Then
            For i = .ListCount - 1 To 0 Step -1
                If InStr(1, .List(i), .Text, 1) = 0 Then .RemoveItem i
            Next i
            .DropDown
        End If
    End With
End Sub


Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    IsArrow = KeyCode = vbKeyUp Or KeyCode = vbKeyDown
    If KeyCode = vbKeyReturn Then Me.ComboBox1.List = Range("A1:A1000").Value
End Sub


Private Sub UserForm_Initialize()
    With Me.ComboBox1
        .RowSource = ""
        .List = Range("A1:A1000").Value
    End With
End Sub
 
Upvote 0
Thanks YaserKhalil
its good but when I run code it show error: Variable not found
and it show IsArrow.

I think it must be define as Integer
I defined but it show error again whit this vlookup code (red Color) that I have in userform code:
Code:
Private Sub ComboBox2_Change()
     Dim Isarrow As Integer
     Dim i As Long
     Dim ws As Worksheet
    Set ws = Worksheets("Sheet2")
   [COLOR=#ff0000] Me.TextBox1.Value = Evaluate("VLOOKUP(""" & Me.ComboBox2 & """,Sheet2!B:C,2,FALSE)")[/COLOR]
    With Me.ComboBox2
        If Not Isarrow Then .List = Range("B2:B600").Value
        If .ListIndex = -1 And Len(.Text) Then
            For i = .ListCount - 1 To 0 Step -1
                If InStr(1, .List(i), .Text, 1) = 0 Then .RemoveItem i
            Next i
            .DropDown
        End If
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

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