Hi
I'm tryn to make a macro that will filter my table in the activesheet. I have 9 sheets and each sheet has the same table on it, just different data.
What I'm tryn to do is, when I'm on a sheet and I enter a value in N1 nothing happens(thats good) and when I enter a value in P1 (the filtering starts) - so N1 is the first criteria and P1 is the second criteria.
I'm also tryn to do if I delete the value in N1 and hit enter that it filters the field 3 and 5 so it has no criteria set (table back to normal).
Here is the code I came up with but sadly it doesn't work 
The code is under VBA Workbook:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target = Range("N1") Then
If Target = Empty Then
ActiveSheet.ListObjects(1).Range.AutoFilter Field:=3
ActiveSheet.ListObjects(1).Range.AutoFilter Field:=5
Range("P1") = Empty
End If
ElseIf Target = Range("P1") And Not Target.Offset(0, -2) = Empty Then
ActiveSheet.ListObjects(1).Range.AutoFilter Field:=3, Criteria:=Range("N1")
ActiveSheet.ListObjects(1).Range.AutoFilter Field:=5, Criteria:=Range("P1")
End If
End Sub
The red part is my error, but if the first criteria is an error the so will the second one be
Bookmarks