Hello,
I try to write item in combobox1 to autocomplete-with-drop-down-box for many items , but show error subscript out of range
If InStr(1, ComboBox1.Value, vList1(n), vbTextCompare) > 0 Then
any help to overcome this problem,please?
Hello,
I try to write item in combobox1 to autocomplete-with-drop-down-box for many items , but show error subscript out of range
If InStr(1, ComboBox1.Value, vList1(n), vbTextCompare) > 0 Then
any help to overcome this problem,please?
Hi again Abdo.
Not sure what you're doing here but the error arises in the ComboBox1_Change() routine behind UserForm1.
It's because you test for an array element vList1(n) but it hass a second dimension so should read vList1(n, 1). A similar error is inyour Select Case Mtch block (corrrected in bold in the code extract below and within the attached file).
Mtch = ""
' loop through array, looking for any matches
For n = LBound(vList1) To UBound(vList1)
' if matched, set Mtch to True
If InStr(1, ComboBox1.Value, vList1(n, 1), vbTextCompare) > 0 Then
' stop on first match
Mtch = vList1(n, 1)
Exit For
End If
Next n
' do actions for whatever was matched
Select Case Mtch
Case vList1(1, 1) ' for SALES INVOICE
TextBox2.Enabled = True
TextBox2.SetFocus
TextBox3.Enabled = False
Case vList1(2, 1) ' For CASH PAID
TextBox2.Enabled = False
TextBox3.Enabled = True
TextBox3.SetFocus
Case vList1(3, 1) ' For CASH RECEIVED
TextBox2.Enabled = True
TextBox3.Enabled = False
TextBox2.SetFocus
' add other cases HERE
Case Else ' if no match
TextBox2.Enabled = False
TextBox3.Enabled = False
End Select
End Sub
Hope this fixes things for you- if so, please mark this Answer as Selected.