Results 1 to 2 of 2

Thread: VBA: Applying Autofilter to range including pivot

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    VBA: Applying Autofilter to range including pivot


    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?

    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

  2. #2
    Managed to solve it by selecting the only the last cell in the header row and applying the filter to it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts