![]() |
macro to turn pivot table field on and off
I have four pivot views, D Rank, S Rank, B Rank and O Rank. I know
how to add an items as illustrated below below, however removing it errors when it's actually not there...how do I avoid this is my question? ActiveCell.FormulaR1C1 = "Data Completeness Rank" ' if the Pivot field is not showing I error out just below ActiveSheet.PivotTables("PivotTable1").PivotFields ("S Rank").Orientation _ = xlHidden ActiveSheet.PivotTables("PivotTable1").PivotFields ("B Rank"). _ Orientation = xlHidden ActiveSheet.PivotTables("PivotTable1").PivotFields ("O Rank"). _ Orientation = xlHidden ActiveSheet.PivotTables("PivotTable1").AddDataFiel d ActiveSheet.PivotTables( _ "PivotTable1").PivotFields("DC Rank"), "Sum of DC Rank", xlSum |
macro to turn pivot table field on and off
Have you tried
On Error Resume Next HTH Bob "S Himmelrich" wrote in message ... I have four pivot views, D Rank, S Rank, B Rank and O Rank. I know how to add an items as illustrated below below, however removing it errors when it's actually not there...how do I avoid this is my question? ActiveCell.FormulaR1C1 = "Data Completeness Rank" ' if the Pivot field is not showing I error out just below ActiveSheet.PivotTables("PivotTable1").PivotFields ("S Rank").Orientation _ = xlHidden ActiveSheet.PivotTables("PivotTable1").PivotFields ("B Rank"). _ Orientation = xlHidden ActiveSheet.PivotTables("PivotTable1").PivotFields ("O Rank"). _ Orientation = xlHidden ActiveSheet.PivotTables("PivotTable1").AddDataFiel d ActiveSheet.PivotTables( _ "PivotTable1").PivotFields("DC Rank"), "Sum of DC Rank", xlSum |
All times are GMT +1. The time now is 04:30 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com