I have the user form with text box and list box
With the below code I am trying to search the customer number while the user enter the name in text box 11 and the list box will display the result.
But this code is not working.
In column B the name is entered and it starts with row 7. The list box should display search details from B to D
Help! as not sure Why the code is not working.
Code.
Private Sub TextBox11_Change()
Dim i As Long
On Error Resume Next
Me.TextBox11.Text = StrConv(Me.TextBox11.Text, vbProperCase)
Me.ListBox1.Clear
For i = 7 To Application.WorksheetFunction.CountA(Sheet1.Range("B:B"))
For x = 1 To 3
a = Len(Me.TextBox11.Text)
If Left(Sheet1.Cells(i, x).Value, a) = Me.TextBox11.Text And Me.TextBox11.Text <> "" Then
Me.ListBox1.AddItem Sheet1.Cells(i, 1).Value
For c = 1 To 3
Me.ListBox1.List(ListBox1.ListCount - 1, c) = Sheet1.Cells(i, c + 1).Value
Next c
End If
Next x
Next i
End Sub
With the below code I am trying to search the customer number while the user enter the name in text box 11 and the list box will display the result.
But this code is not working.
In column B the name is entered and it starts with row 7. The list box should display search details from B to D
Help! as not sure Why the code is not working.
Code.
Private Sub TextBox11_Change()
Dim i As Long
On Error Resume Next
Me.TextBox11.Text = StrConv(Me.TextBox11.Text, vbProperCase)
Me.ListBox1.Clear
For i = 7 To Application.WorksheetFunction.CountA(Sheet1.Range("B:B"))
For x = 1 To 3
a = Len(Me.TextBox11.Text)
If Left(Sheet1.Cells(i, x).Value, a) = Me.TextBox11.Text And Me.TextBox11.Text <> "" Then
Me.ListBox1.AddItem Sheet1.Cells(i, 1).Value
For c = 1 To 3
Me.ListBox1.List(ListBox1.ListCount - 1, c) = Sheet1.Cells(i, c + 1).Value
Next c
End If
Next x
Next i
End Sub