Filter based on data entered into cell

  • Thread starter Thread starter Cards1986
  • Start date Start date
C

Cards1986

I have a rater large spreadsheet that I would like to make as user friendly
as possible. I want the users to type in what they are wanting to filter
for in a cell and then let excel filter the spreadsheet based on what data
they entered. After filtering the list maybe they could click a button that
would reset the list and let them filter for another item. Is this possible
and how? Thanks!!!
 
You could use autofilter and VBA with an input box to enter the criteria, I
made a few for a phone list at work with a reset button as well

Here's an example that filters on the area code

Sub Area_Code()
Application.ScreenUpdating = False
UserVal = Application.InputBox("Enter Area Code")
If UserVal = False Then
Exit Sub
Else
Selection.AutoFilter Field:=4, Criteria1:=UserVal & "*", Operator:=xlAnd
End If
Application.ScreenUpdating = True
End Sub

here's how to reset it

Sub Reset_Filter()
Application.ScreenUpdating = False
For Each sh In Worksheets
If sh.FilterMode Then
On Error Resume Next
sh.ShowAllData
End If
Next
Application.ScreenUpdating = True
End Sub
 
What I had in mind was to leave a blank row above my data so that the user
could type in a cell or maybe even multiple cells then click a button to
have the list filtered by the data requested. Kind of like a searh and
filter on a spreadsheet. How hard or possible is this? Thanks!!!!
 
Back
Top