Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim PVF1 As PivotField, PVF2 As PivotField
Dim i As Long
Set PVF1 = ActiveSheet.PivotTables("PivotTable1").PivotFields("Code")
Set PVF2 = ActiveSheet.PivotTables("PivotTable2").PivotFields("Code")
Application.EnableEvents = False
For i = 1 To PVF2.PivotItems.Count
PVF2.PivotItems(i).Visible = PVF1.PivotItems(i).Visible
Next i
Application.EnableEvents = True
End Sub