Saturday, October 7, 2017

MS Excell Listbox Search By Textbox VBA

VBA Code

Private Sub UserForm_Initialize()
End Sub

Private Sub TextBox1_Change()
Me.TextBox1.Text = StrConv(Me.TextBox1.Text, vbProperCase)
Dim i As Long
On Error Resume Next
For i = 1 To Application.WorksheetFunction.CountA(Sheet1.Range("A:A"))
a = Len(Me.TextBox1.Text)
If Left(Sheet1.Cells(i, 1).Text, a) = Left(Me.TextBox1.Text, a) Then
Me.ListBox1.AddItem Sheet1.Cells(i, 1).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = Sheet1.Cells(i, 2).Value
End If
Next i
End Sub


  1. a minha len é sempre só 1 carácter?

  2. In the same userform how to select and add that searched item to another sheet,,, which code to apply for adding item from same list box to another sheet .sir please reply on this. By giving code. Of add item to another sheet...
    From Pritesh
    Sir if you will give that code through email then it will be useful for. Me... Pleased sir I am searching for this code. From more then 3 months and watched more then 100 videos from various channels....
    Watsapp: 8980543514


Please do not enter any spam message in comment box