• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Filtering Pivot Table

Hi Experts,

I am trying to apply filter pivottable based on a cell value as below but my code is not working and it's throwing up error 1004.

Any input on this is appreciated ?


Code:
Worksheets(1).Activate
    Dim pt As PivotTable
    Dim Field As PivotField
    Dim rValTL As String
   
    Set pt = Worksheets(1).PivotTables("pivottable4")
    Set Field = pt.PivotFields("Date")
    rValTL = Wb2.Sheets("Macro").Range("K1").Value
    With pt
        Field.ClearAllFilters
        Field.CurrentPage = rValTL
        pt.RefreshTable
      End With
 
Which line of code is causing the error? When you hit debug, which line it highlighted?
 
Try
Code:
Debug.Print rValTL

And see what comes up in immediate window.
Likely cause of the error is date format mismatch (or simply that rValTL isn't found in "Date" Field).
 
Back
Top