I have a userform which searches a database of numbered entries, returning all instances of the search word in textbox6 from two columns of the database.
The final control will be ComboBox2 (a YES NO choice)
If YES the code is to remove entries from the retrieved listings that begin with "20" only
If NO the code is to remove entries from the retrieved listings that begin with "19" only
How can I adapt the following
Private Sub TextBox6_Change()
Dim a, i As Long, w(), n As Long
Me.ListBox4.Clear
If Me.TextBox6.Value = "" Then Exit Sub
a = Sheets("ewccodes").Cells(1).CurrentRegion.Value
For i = 2 To UBound(a, 1)
If UCase$(a(i, 3)) Like "*" & UCase$(Me.TextBox6.Value) & "*" Or UCase$(a(i, 4)) Like "*" & UCase$(Me.TextBox6.Value) & "*" Then
n = n + 1
ReDim Preserve w(1 To UBound(a, 2), 1 To n)
For ii = 1 To UBound(a, 2)
w(ii, n) = a(i, ii)
Next
End If
Next
If n > 0 Then Me.ListBox4.Column = w
End Sub
Any help appreciated
Bookmarks