更改数据透视表的选择时如何自动运行宏 [英] How to run a macro automatically when the selections of pivot tables are changed
本文介绍了更改数据透视表的选择时如何自动运行宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据透视表,其中显示了Quarters的数据,还有一个宏,它根据数据透视表中的数据执行一些计算.因此,现在我想在更改枢纽项目的选择时自动运行宏,例如select Quarter1,它将显示Q1的值并自动运行宏,以便它计算Q1的值,并且所有选择(包括多个选择..
I got a pivot table with shows the data for Quarters in it, and a macro that performs some calculations based on the data in pivot table. So now I want to run the Macro automatically when I changed the selection of pivot items, like if select Quarter1 , it shows the values for Q1 and run the macro automatically so that it calculate the values for Q1, and same for all selections including the multiple selections..
推荐答案
在具有数据透视表的工作表的代码模块中放入以下内容:
Put something like this in the code module of the worksheet with the pivot table:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
' Call your macro here
End Sub
这篇关于更改数据透视表的选择时如何自动运行宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文