PDA

View Full Version : Solved: TXTbox filter



danovkos
11-11-2010, 07:01 AM
Hi all,
pls. how can i do following.

I have data table (sample).

I want to appear only data, which equal to criteria in textbox.

I mean, it will search by name (column A).

I write e.g. "ar" it will appera only data wich contain in name character "ar". In my sample only data for "car" and "darling". Ideal will be, when it will search during writting. If is txt box clear, all data will appear.

THX a lot for help.

Tinbendr
11-11-2010, 08:32 AM
Private Sub TextBox1_Change()
Dim LastRow As Long

LastRow = Range("A65535").End(xlUp).Row

If TextBox1.Text <> "" Then
ActiveSheet.Range("$A$2:$C$" & LastRow).AutoFilter Field:=1, _
Criteria1:="=*" & TextBox1.Text & "*" _
, Operator:=xlOr
Else
ActiveSheet.Range("$A$2:$C$" & LastRow).AutoFilter Field:=1
End If


End Sub


David

danovkos
11-12-2010, 12:12 AM
thank you very much
exactly what i needed. :)
:bow: :bow: :clap:

kemas
11-12-2010, 03:45 PM
thanks

i think this must be

Criteria1:="=" & TextBox1.Text & "*"

Aussiebear
11-13-2010, 02:17 AM
It appears to work as David suggested.