Filter based on data entered into cell

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!!!
 
P

Peo Sjoblom

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
 
C

Cards1986

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!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top