Thread: Macro Help!!
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan[_9_] Rowan[_9_] is offline
external usenet poster
 
Posts: 88
Default Macro Help!!

Assuming your pivot tables are called PivotTable1 and PivotTable2 then
you could use this worksheet change event.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim itm As PivotItem
Dim shop As PivotField

On Error GoTo ErrorHandler
Application.EnableEvents = False

Set shop = Me.PivotTables("PivotTable1"). _
PivotFields("Shop")
For Each itm In Me.PivotTables("PivotTable2"). _
PivotFields("Shop").PivotItems
itm.Visible = shop.PivotItems(itm.Caption).Visible
Next itm
Set shop = Nothing
Set itm = Nothing
ErrorHandler:
Application.EnableEvents = True

End Sub

This is worksheet event code. Right click the sheet tab, select View
Code and paste the code in there.

Hope this helps
Rowan

Dennis Cheung wrote:
dear masters,

This is the 2nd time I post this subject but I got no reply. Can anyone
kindly let me know if my task is possible. Or I will think to do it the other
way.

There are two pivot tables in one sheet. they are from the same source in an
Access data base. Actually the 2nd one is a copy of the first one.
In the page area, both PVTs had a field "Shop". I need a Marco to do the
follwoing.
When I select a shop in PVT1, the 2nd PVT will select the same shop
automatically.
Is it possible to perform the above tasks? Please help!