PDA

View Full Version : Set pivot filters to match another pivot table



werafa
08-24-2025, 03:54 AM
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

werafa
08-24-2025, 04:09 AM
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

georgiboy
08-24-2025, 06:47 AM
Instead of dates, have you tried dimming the dates as Long type?

werafa
08-25-2025, 01:38 AM
I've not. I'll do this, and report back. will try string too.