Dear Excel wizards
I have a listview with six columns.
How do I search for a value in the first column?
I assume that it's column 0, isn't it?
Example to search for value 59:
I get invalid property value (at Subitems(0) )
Is there any other way to search for a value in the first column?
My second question about the listview is about the search type: Is possible to create a wildcard search or a 'like' search which searches for similar values?
Thanks
Maria
I have a listview with six columns.
How do I search for a value in the first column?
I assume that it's column 0, isn't it?
Example to search for value 59:
Code:
FindItem "59", lvwCustomers, 0,
Code:
Public Sub FindItem(strSearch As String, lvw As ListView, iSubItemIndex As Integer, bExact As Boolean)
For i = lvw.SelectedItem.Index + 1 To lvw.ListItems.count
If (bExact And lvw.ListItems(i).SubItems(0) = strSearch) _
Or InStr(lvw.ListItems(i).SubItems(0), strSearch) > 0 Then
With lvw.ListItems(i)
.Selected = True
.EnsureVisible
End With
bFound = True
Exit For
End If
Next
If Not bFound Then
MsgBox "Search Item'" & UCase$(strSearch) & "' not found..", vbInformation, ""
'Go back to the start
With lvw.ListItems(1)
.Selected = True
.EnsureVisible
End With
End If
I get invalid property value (at Subitems(0) )
Is there any other way to search for a value in the first column?
My second question about the listview is about the search type: Is possible to create a wildcard search or a 'like' search which searches for similar values?
Thanks
Maria