I have a form that I have been struggling with and the types of excel built in functions haven't achieved what I want. This is want; I want to include a string query from a textbox and if the text partially matches; it will add it to the listbox as a complete text. I have this:
Private Sub cmdExecute_Click()
Dim x As Long, keyword As Variant, val As String
keyword = Array("MP0", "SS0", "IP0", "F-")
Me.lbPN.Clear ' listbox name
' this incorporates part number to extract MP, IP, SS, & F-
Dim i As Long, lRow As Long
Dim ws As Worksheet
Set ws = Application.Worksheets("routing details")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lRow
If Replace(ws.Cells(i, 1).Value, " ", "") = Replace(Me.txtKeyword.Value, " ", "") Then
For x = 0 To 3
If Range("V" & i).Value Like "*" & keyword(x) & "*" Then
val = "This where I want keyword + the rest of the text of that completed string"
End If
With Me.lbPN
.AddItem val
End With
Next x
End If
Next i
Please share your ideas. Thanks!
Bookmarks