Hello!

I am trying to apply autofilter to range which includes a pivot, but i keep getting an "Autofilter method or Range class failed" error.


Lets say the range is A1:J100. The pivot is in between A1:G100. When manually applying the filter I just select the full range, press Ctrl+shift+L and it applies an autofilter even though there is a pivot. However when I do it with VBA, it doesnt allow it. Could anybody help please?

Code:

With wb   

Set chk1AnalysRng = .Range("A1", .cells(.Range("A1").End(xlDown).Row,.Range("A1").End(xlToRight).Column))

End With

With chk1AnalysRng 

   .AutoFilter '<--- Error 
   .AutoFilter field:=3, Criteria1:=Key 
   .AutoFilter field:=8, Criteria1:="<>"

End With