AlwaysLearning
New Member
I need help putting 2 separate conditions for filtering a large spreadsheet. Each of the filters work well separately but I'm trying to figure a way to put them together so if either criteria cells or both are filled, the data would be filtered accordingly.
Here is a summary of my case: My spreadsheet has about 20 columns and about 20,000 rows. Column "C" (3rd column) has location # and Column N (14th column) has a regional director name. If I put a location number in cell D1, the filter below filters the data to show only the rows that match that location number from column C.
If I want to filter by the name of the director, I filter below filters the data to show only the rows that match that director's name from Column N which would have multiple locations.
I'd like to combine both filters so if I put a location number in D1 and a director's name in J1, the data would be filtered to match both criteria.
Thanks in advance for your help
Here is a summary of my case: My spreadsheet has about 20 columns and about 20,000 rows. Column "C" (3rd column) has location # and Column N (14th column) has a regional director name. If I put a location number in cell D1, the filter below filters the data to show only the rows that match that location number from column C.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Set Target = Target.Cells(1, 1)
If Not Intersect(Target, Range("D1")) Is Nothing Then
Range("A6").CurrentRegion.AutoFilter field:=3, Criteria1:=Target.Value
End If
End Sub
If I want to filter by the name of the director, I filter below filters the data to show only the rows that match that director's name from Column N which would have multiple locations.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Set Target = Target.Cells(1, 1)
If Not Intersect(Target, Range("J1")) Is Nothing Then
Range("A6").CurrentRegion.AutoFilter field:=14, Criteria1:=Target.Value
End If
End Sub
I'd like to combine both filters so if I put a location number in D1 and a director's name in J1, the data would be filtered to match both criteria.
Thanks in advance for your help