Consulting

Results 1 to 6 of 6

Thread: Set pivot filters to match another pivot table

  1. #1
    VBAX Mentor
    Joined
    Aug 2012
    Posts
    375
    Location

    Set pivot filters to match another pivot table

    Hi,

    I have several pivot tables set to different pivotcaches that I wish to control from a single timeline slicer.

    I am able to program the filter settings using
    .PivotFields("Date").PivotFilters.Add2 Type:=xlDateBetween, Value1:=startDate, Value2:=endDate
    I now need to read the filter state of the primary pivot, get startDate and endDate, and apply this to the subordinate pivots - but can not deduce the correct object properties to call/read.
    (this is currently triggered by a pivottable change event - am attempting to read values from "Target")

    Can anyone assist?
    Thanks
    Werafa
    Last edited by werafa; 08-24-2025 at 04:10 AM.
    Remember: it is the second mouse that gets the cheese.....

  2. #2
    VBAX Mentor
    Joined
    Aug 2012
    Posts
    375
    Location
    progress

    Have lucked onto the syntax to read values from target
    If Target.Name <> "pvtBudget" Then Exit Sub
        startDate = Target.ActiveFilters.Item(1).Value1
        endDate = Target.ActiveFilters.Item(1).Value2
    am now getting a "This isn't a valid date" error when applying as posted above.
    but the variables are dimmed as date type - so the values are valid dates.

    any ideas why this is happening, or a better way to apply the filters?
    thanks again
    Werafa
    Remember: it is the second mouse that gets the cheese.....

  3. #3
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,308
    Location
    Instead of dates, have you tried dimming the dates as Long type?
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

  4. #4
    VBAX Mentor
    Joined
    Aug 2012
    Posts
    375
    Location
    I've not. I'll do this, and report back. will try string too.
    Remember: it is the second mouse that gets the cheese.....

  5. #5
    VBAX Mentor
    Joined
    Aug 2012
    Posts
    375
    Location
    thanks
    long data type solved it
    Remember: it is the second mouse that gets the cheese.....

  6. #6
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,308
    Location
    Glad it worked for you, thanks for reporting back.
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

Posting Permissions

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