linked pivot tables

pkhoo

New Member
Joined
Dec 8, 2002
Messages
9
does anyone know how to link two pivot tables together so that their page selections are synchronized together.

ie if pivot has a page for each region. if the region is change in the first pivot table somehow the second pivot is change as well?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
On 2002-12-09 23:12, Juan Pablo G. wrote:
Yes, you can do this using the _Change() event of the worksheet. Have you used macros ?

I would love to know how this can be done
 
Upvote 0
i have not use the macros before but am familiar with Access VB. would you put the change worksheet with the module or the worksheet???
 
Upvote 0
Hi Juan,

i have piece together after browsing through this and other forums. But it does not seem to work. Here's my code attached to the worksheet with the pivot tables.

Sub Worksheet_Change(ByVal Target As Range)
'synchronize L3 parent location between pivot2 dependent pivot3 pivot4
'Find name of page field
'PivotTable2 is the lead pivot table
MsgBox "hello"
PageField2 = ActiveSheet.PivotTables("PivotTable2").PageFields(1)
pvt2page = ActiveSheet.PivotTables("PivotTable2").PivotFields(PageFields1).CurrentPage

PageField3 = ActiveSheet.PivotTables("PivotTable3").PageFields(1)
ActiveSheet.PivotTables("PivotTable3").PivotFields(PageFields3).CurrentPage = pvt2page

PageField4 = ActiveSheet.PivotTables("PivotTable4").PageFields(1)
ActiveSheet.PivotTables("PivotTable4").PivotFields(PageFields4).CurrentPage = pvt2page

End Sub
 
Upvote 0
Changing the Page Field does not seem to trigger either the Worksheet_Change event or the Worksheet_SelectionChange event. But this worked for me:

Code:
Private Sub Worksheet_Calculate()
    Dim PF1 As PivotField
    Dim PF2 As PivotField
    Dim x As String
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Set PF1 = ActiveSheet.PivotTables("PivotTable1").PageFields(1)
    Set PF2 = ActiveSheet.PivotTables("PivotTable2").PageFields(1)
    x = PF1.CurrentPage
    PF2.CurrentPage = x
    Application.ScreenUpdating = True
    Application.EnableEvents = True
End Sub
 
Upvote 0
hi juan,
a change in the pivot table page dropdown does not seem to trigger the worksheet_change event ????? workarounds???

help!
 
Upvote 0
Hi gus this looked like a neat solution to a problem I had of linking three pivot tables each with 5 page fields. However, when I put the code (below) nothing happened. In fact when I ran the code I got the run-time error 1004 message saying application define or object defined error.

Any help

Cheers
Mark

Private Sub Worksheet_Calculate()

Dim PF1 As PivotFields
Dim PF2 As PivotFields
Dim PF3 As PivotFields
Dim X As String

Application.EnableEvents = False
Application.ScreenUpdating = False

Set PF1 = ActiveSheet.PivotTables("PivotTable3").PageFields
Set PF2 = ActiveSheet.PivotTables("PivotTable1").PageFields
Set PF3 = ActiveSheet.PivotTables("PivotTable4").PageFields

X = PF1.CurrentPage
PF2.CurrentPage = X
PF3.CurrentPage = X

Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub
 
Upvote 0
Private Sub Worksheet_Calculate()

Dim PF1 As PivotFields
Dim PF2 As PivotFields
Dim PF3 As PivotFields
Dim X As String

Application.EnableEvents = False
Application.ScreenUpdating = False

Set PF1 = ActiveSheet.PivotTables("PivotTable3").PageFields
Set PF2 = ActiveSheet.PivotTables("PivotTable1").PageFields
Set PF3 = ActiveSheet.PivotTables("PivotTable4").PageFields

X = PF1.CurrentPage
PF2.CurrentPage = X
PF3.CurrentPage = X

Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub

Just came across this and wondered if it can be modified so that should you "Select Multiple Items" the selection would be replicated on the second pivot.

Martin
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,947
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top