Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pivot table dropdown doesn't trigger worksheet_change

Status
Not open for further replies.

pkhoo

MIS
Dec 6, 2002
15
US
Hi
i am new to Excel VBA but have some experience in Access.

I have a macro that will update the dependent pivot tables base on the first one using the worksheet_change trigger. However, when the pivot page dropdown was change, it didn't work - only if other cells was changed. If I use the _calculate event, it spreadsheet spins into an infinite loop.?? i appended the code below - hope somebody could help me

Private Sub Worksheet_Change(ByVal Target As Range)
'synchronize L3 parent location between pivot2 and dependent pivot3 pivot4
'Find name of page field
'PivotTable2 is the lead pivot table
'not working because change in pull down does not trigger worksheet change
'using w~ calc goes into infinite loop
MsgBox "hello"

PageField2 = ActiveSheet.PivotTables("PivotTable2").PageFields(1)
pvt2page = ActiveSheet.PivotTables("PivotTable2").PivotFields(PageField2).CurrentPage

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

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


End Sub


 
To stop the infinite loop use

application.enableevents = false
'code
'code
'code
application.enableevents = true
Rgds
~Geoff~
 
thank you!
i got it to work! amazing
peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top