How can I filter already filtered data? (Autofilter+VBA)

David2

New Member
Joined
Jan 13, 2018
Messages
39
I'm using auto filter (Criteria1:="*abc*") to filter some data. I'd like to use another filter on that data, this time using UserInput as Criteria.


How can I set up my vba code to have user input filter search the filtered data instead of resetting and searching the unfiltered data instead?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Test:

Code:
dato = InputBox("Criteria")
If dato = "" Then Exit Sub
ActiveSheet.Range("$A$1:$B$4").AutoFilter Field:=2, Criteria1:="*" & dato & "*"
 
Upvote 0
Dante, thank you for your reply but I'm afraid I forgot to add one important thing.

Data for my first criteria ('abc') is in column B and I'd like to have my input criteria filter based on values in column C.
 
Upvote 0
I'm not following you, could you put your complete code? Could you give an example of what you have on your sheet?

Or maybe it's something like this:
Put the following code in the events of your sheet

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("C1")) Is Nothing Then
        If Target.Count > 1 Then Exit Sub
        dato = Range("C1").Value
        u = Range("B" & Rows.Count).End(xlUp).Row
        ActiveSheet.Range("$A$1:$B$4").AutoFilter Field:=2, Criteria1:="*" & dato & "*"
    End If
End Sub


If you put "abc" in cell C1, automatically the data in column B will be filtered with the data of C1
 
Upvote 0

Forum statistics

Threads
1,215,352
Messages
6,124,453
Members
449,161
Latest member
NHOJ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top