Auto Filter depending on Cell Value

Hello, 
I have data in a table, lets say the table is (A7:M200) and the Headings in this table is (A7:M7). Column 1 (A8:A200) is the accounts numbers. I already selected the Row 7 (the headings in this table) then I made Auto filtering. Now my request is when I write in Cell (E1) any account number to filter that table (A8:M200) according to this selection in E1. Thank you in advance for any kind assistant. Issa
1. Open the file 
2. Press ALT + F11 
3. Press CTRL + R 
4. Double click on the sheet where you want this functionality 
5. Paste the code 

Private Sub Worksheet_Change(ByVal Target As Range) 
   If (Intersect(Target, Range("E1")) Is Nothing) _ 
   Then 
      Exit Sub 
   End If 
   Cells.AutoFilter Field:=1, Criteria1:="=" & Range("E1") 
End Sub


This is based on assumption that you want to filter the 1st column (column A). Change value of "Field" to point to right column 

By the way you can use wild card in E1 like 
1234* ( some thing that starts with 1234) 
123?56??? (some thing that start with 123, then has some character, followed by 56 followed by three charachters 
*1234* (some thing that has 1234 some where)

Private Sub Worksheet_Change(ByVal Target As Range)
If (Intersect(Target, Range("E1")) Is Nothing) _
Then
Exit Sub
End If
Cells.AutoFilter Field:=1, Criteria1:="=" & Range("E1")
End Sub

This is based on assumption that you want to filter the 1st column (column A). Change value of "Field" to point to right column 

By the way you can use wild card in E1 like 
1234* ( some thing that starts with 1234) 
123?56??? (some thing that start with 123, then has some character, followed by 56 followed by three charachters 
*1234* (some thing that has 1234 some where)

This is based on assumption that you want to filter the 1st column (column A). Change value of "Field" to point to right column 

By the way you can use wild card in E1 like 
1234* ( some thing that starts with 1234) 
123?56??? (some thing that start with 123, then has some character, followed by 56 followed by three charachters 
*1234* (some thing that has 1234 some where)

This is based on assumption that you want to filter the 1st column (column A). Change value of "Field" to point to right column 
By the way you can use wild card in E1 like 
1234* ( some thing that starts with 1234) 
123?56??? (some thing that start with 123, then has some character, followed by 56 followed by three charachters 
*1234* (some thing that has 1234 some where)

By the way you can use wild card in E1 like 
1234* ( some thing that starts with 1234) 
123?56??? (some thing that start with 123, then has some character, followed by 56 followed by three charachters 
*1234* (some thing that has 1234 some where)



Download example  here....

Source:  http://en.kioskea.net/forum/affich-607114-auto-filter-depending-on-cell-value


No comments: