I have two pivot tables in Excel 2010 with the same data source, the only difference being the way they are displayed. Filtering is linked via slicers however I want the show detail to be linked bit I'm struggling. I've pasted some code below that is not working but if it worked would do what I need. That said it's surely not the best code. I'm really keen on some advice.

Sub Macro1()

Dim i, j As Integer
i = 0
j = 0

For Each pf In Sheet4.PivotTables("PivotTable1").PivotFields
i = i + 1
For Each pi In pf.PivotItems
j = j + 1
Sheet4.PivotTables("PivotTables1").PivotFields(i).PivotItems(j).ShowDetail = Sheet2.PivotTables("PivotTables2").PivotFields(i).PivotItems(j).ShowDetail
Next pi
Next pf

End Sub