I am trying to grab a cell value and use it to filter a pivot table. I tried to record a macro doing this but it appears to store the value in the code instead of using a variable (like cell G1). Any ideas on how to pass a cell value in place of the "cmi" value?
我试图获取单元格值并使用它来过滤数据透视表。我试图记录一个这样做的宏,但它似乎将值存储在代码中而不是使用变量(如单元格G1)。关于如何传递单元格值代替“cmi”值的任何想法?
Range("G1").Select
Selection.Copy
Sheets("Sheet4").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("field").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("field").CurrentPage = "cmi"
1 个解决方案
#1
0
Remove the line with .ClearAllFilters
.
删除.ClearAllFilters行。
#1
0
Remove the line with .ClearAllFilters
.
删除.ClearAllFilters行。