Hi,
I can't see why the following VBA code won't work - is that always the case. I have two pivot tables on one sheet. I have hidden most of the second pivot table which includes the fields to filter by. The two pivots use the same four fields so I want a change made to one of the fields on the main pivot to also chaneg the data on the second.
The code I have written compiles but the pivot seems to flash for a split second with the correct change and reverts to its orginal.
e.g If I change FinYear to 2009/10 in my main pivot the second pivot flashes briefly with 2009/10 and then reverts to 2008/09.
I have attached my code as a text file to make my post shorter. it's quite simple...or should be.
If you would prefer I post it in full here, let me know.
I would apprecate any and all help.
Without seeing the files etc it's obviously hard to comment but as I see it you're only ever referring to pt1
which we assume relates to 2nd pivot...Code:Set pt1 = ws.PivotTables("RIW2")
however, you're then using an approach of:
all this will do is go to All and then revert to original setting... you should I think be basing mVAT off Target rather than pt1....ie:Code:mvAT = pt1.PivotFields(strField1).CurrentPage With pt1.PageFields(strField1) .CurrentPage = "(All)" For Each pi In .PivotItems If pi.Value = mvAT Then .CurrentPage = mvAT Exit For End If Next pi End With
in the above we're assuming you're only setting filters via 1st Pivot - it's not an either/or affair.Code:mvAT = Target.PivotFields(strField1).CurrentPage
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks