Hi ,
The code itself is straightforward ; there are two modules :
Code:
Private Sub TextBox1_Change()
Range("A2").AutoFilter 1, "*" & [A1] & "*"
End Sub
This is an event procedure , which is invoked whenever any change is made in the text box ; whenever you add / change / delete characters in the text box , this code runs the in-built
AutoFilter , with whatever characters are available in the text box ; the linked cell of the text box has been put to cell A1 , whose cell format has been put to a white font so that the characters are not visible. Any text that is entered in the text box is immediately available in cell A1 ; the criterion for the
AutoFilter is :
"*" & [A1] & "*"
which means the text string entered in the text box can be embedded anywhere in the database cells. Thus a text string of amdy will match the following entries :
Fatmaalzahraa Hamdy Fathy Ahmed
Haytham Hamdy Gamal
The other module is :
Code:
Sub Button4_Click()
Sheet1.AutoFilterMode = False
Sheet1.TextBox1.Text = ""
End Sub
This resets the
AutoFilter so that all entries are displayed once more ; also the text which had been entered in the text box is cleared so that fresh data can be entered.
Narayan