VBA枢轴对象选择列范围 [英] VBA pivot object select columnrange
问题描述
我在数据透视表中有以下数据
列是月份和年份
行分为产品,它们显示每月和每年的收入。
我试图用当前年份和月份过滤数据透视表中的数据/// 4
到目前为止,我已根据录制的宏编码以下简单代码。如何过滤列范围?
Sub Button2_Click()
设置pT = PivotTables(" PivotTable1")
pT.ColumnRange.Select
使用pT
.ClearAllFilters
.PivotFields(" [Period - Pricing date]。[Month]。[Month]" ;)。PivotFilters.Add类型:= xlAllDatesInPeriodFebruary
'.PivotFields(" [Period - Pricing date]。[Month]。[Month]")。PivotFilters.Add:=" February"
结束时
结束子
我在数据透视表中有以下数据
列是月份和年份
行被分组到产品中,它们显示每月和每年的收入。
我正在尝试过滤数据透视表中的数据包含当前年份和月份/// 4
到目前为止,我已基于a编写以下简单代码录制的宏。如何过滤列范围?
Sub Button2_Click()
设置pT = PivotTables(" PivotTable1")
pT.ColumnRange.Select
使用pT
。 ClearAllFilters
.PivotFields(" [Period - Pricing date]。[Month]。[Month]")。PivotFilters.Add Type:= xlAllDatesInPeriodFebruary
'.PivotFields(" [Period - Pricing date ]。[月]。[月]")。PivotFilters.Add:=" February"
End with
End Sub
< a href ="https://expirebox.com/download/7970998b7c50780218a52b4b9edb7ee5.html\"target ="_ blank">点击下载
此处下载文件
I have the following data in the pivot table
columns are months and year
rows are grouped into products and they show revenue per month and year.
I am trying to filter the data in the pivot table with current year and month ///4
so far I have been coding the following simple code based on a recorded macro. How can I filter column range?
Sub Button2_Click() Set pT = PivotTables("PivotTable1") pT.ColumnRange.Select With pT .ClearAllFilters .PivotFields("[Period - Pricing date].[Month].[Month]").PivotFilters.Add Type:=xlAllDatesInPeriodFebruary '.PivotFields("[Period - Pricing date].[Month].[Month]").PivotFilters.Add := "February" End With End Sub
I have the following data in the pivot table
columns are months and year
rows are grouped into products and they show revenue per month and year.
I am trying to filter the data in the pivot table with current year and month ///4
so far I have been coding the following simple code based on a recorded macro. How can I filter column range?
Sub Button2_Click() Set pT = PivotTables("PivotTable1") pT.ColumnRange.Select With pT .ClearAllFilters .PivotFields("[Period - Pricing date].[Month].[Month]").PivotFilters.Add Type:=xlAllDatesInPeriodFebruary '.PivotFields("[Period - Pricing date].[Month].[Month]").PivotFilters.Add := "February" End With End Subdownload file here
这篇关于VBA枢轴对象选择列范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!