Hello everyone, I need help with the search in a listview, I have a listview with a textbox with a search button.
Sorry because I´m new using VBA and I´m struggle my mind at don´t know how to do.
At the moment I am using this code it works fine for me, but it only indicates the first match, so I have two questions:
1. How can I make it continue indicating the next match?
2. How I implement the use of wildcards(*) in search?
Thank you very much in advance
code:
Private Sub CommandButton1_Click()
Dim itmx As ListItem
Set itmx = ListView1.FindItem(TextBox1.Text, lvwSubItem, , lvwPartial)
If itmx Is Nothing Then
MsgBox "No matches found", vbExclamation, "Information"
TextBox1.Value = Clean
TextBox1.SetFocus
Else
ListView1.ListItems(itmx.Index).Selected = True
ListView1.SetFocus
End If
End Sub
Sorry because I´m new using VBA and I´m struggle my mind at don´t know how to do.
At the moment I am using this code it works fine for me, but it only indicates the first match, so I have two questions:
1. How can I make it continue indicating the next match?
2. How I implement the use of wildcards(*) in search?
Thank you very much in advance
code:
Private Sub CommandButton1_Click()
Dim itmx As ListItem
Set itmx = ListView1.FindItem(TextBox1.Text, lvwSubItem, , lvwPartial)
If itmx Is Nothing Then
MsgBox "No matches found", vbExclamation, "Information"
TextBox1.Value = Clean
TextBox1.SetFocus
Else
ListView1.ListItems(itmx.Index).Selected = True
ListView1.SetFocus
End If
End Sub