Roshier Garcia
Roshier Garcia

Reputation: 1

Searchable ComboBox

I do not how can I fix this problem, "Permission Denied". I just want to make my combobox, searchable as I type a word.

eg.
List:
Caliper
Pin Holder
Pin SKD11
Dowell Pin

and when I type "PIN", the item appear in the combobox dropdown will be:

Pin Holder
Pin SKD11
Dowell Pin

pls, help me fix the error.

additional note: I used "TABLE" in excel. Sheet: Inventory, Inventory:Table1, Table1:ItemList ' where my dropdown list is come from

Here's my Code: (and I also put my reference link)

Option Explicit
Private IsArrow As Boolean

Private Sub stock_box_Change()
    Worksheets("Inventory").Unprotect "Roshier"
        
    Dim i As Long

    If Not IsArrow Then
    
        With Me.stock_box
            .List = Worksheets("Inventory").Range("F4", Worksheets("Inventory").Cells(Rows.Count, "F").End(xlUp)).Value
            .ListRows = Application.WorksheetFunction.Min(5, .ListCount)
            .DropDown

            If Len(.Text) Then
                For i = .ListCount - 1 To 0 Step -1
                    If InStr(1, .List(i), .Text, vbTextCompare) = 0 Then .RemoveItem i
                Next
                .DropDown
            End If
        End With

    End If

    Worksheets("Inventory").Protect "Roshier"
End Sub

Private Sub stock_box_DropButtonClick()
    With Me.stock_box
        .List = Worksheets("Inventory").Range("F4", Worksheets("Inventory").Cells(Rows.Count, "F").End(xlUp)).Value
        .ListRows = Application.WorksheetFunction.Min(5, .ListCount)
        .DropDown
    End With
End Sub

Private Sub stock_box_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    IsArrow = (KeyCode = vbKeyUp) Or (KeyCode = vbKeyDown)
    If KeyCode = vbKeyReturn Then Me.stock_box.List = Worksheets("Inventory").Range("F4", Worksheets("Inventory").Cells(Rows.Count, "F").End(xlUp)).Value
End Sub

Reference: https://www.mrexcel.com/board/threads/how-to-use-a-combobox-with-autocomplete-and-search-as-you-type.1098277/

I just want to make my combo box, searchable as I type a word.

Upvotes: 0

Views: 188

Answers (1)

Shahid Habibi
Shahid Habibi

Reputation: 1

if you are using c#, you can set property for combobox to readonly=false then it will be solved

Upvotes: 0

Related Questions