Banner

Thursday, July 20, 2017

Listbox FilterTo Other Listbox Userform Exel VBA



Private Sub UserForm_Initialize()
Me.ListBox1.RowSource = "Data"
End Sub

Private Sub TextBox1_Change()
Me.ListBox2.Clear
For i = 0 To Me.ListBox1.ListCount - 1
a = Len(Me.TextBox1.Text)
Me.ListBox1.Selected(i) = False
If Me.TextBox1 <> "" Then
If LCase(Left(Me.ListBox1.List(i, 0), a)) = Me.TextBox1.Text Or _
UCase(Left(Me.ListBox1.List(i, 0), a)) = Me.TextBox1.Text Then
Me.ListBox1.Selected(i) = True
Me.ListBox2.AddItem Me.ListBox1.List(i, 0)
End If
End If
Next i
End Sub


No comments:

Post a Comment

Please do not enter any spam message in comment box