Hi Guys. Could you please look at the code for filtering. by typing Emma in the box I 'd like to see all the Rows are including Emma, I can see two instead of five Emma in data table. file attached. here is the code:
Code:
Private Sub TextBox1_Change()
Dim c, col As Long
With ActiveSheet.ListObjects("ContactList")
.AutoFilter.ShowAllData
With ActiveSheet.ListObjects("ContactList").DataBodyRange
Set c = .Find([E4].Value, .Cells(1), xlValues, xlWhole, xlColumns)
If Not c Is Nothing Then
Debug.Print [E4]
col = c.Column - 2
ElseIf Len([E4].Value) = 0 Then
Call clearFilter
Exit Sub
Else
Exit Sub
End If
End With
.Range.AutoFilter Field:=col, Criteria1:="*" & [E4] & "*", Operator:=xlFilterValues
End With
End Sub
Sub clearFilter()
[E4] = ""
ActiveSheet.ListObjects("ContactList").AutoFilter.ShowAllData
End Sub
Attachments
Last edited by a moderator: