nniedzielski
Well-known Member
- Joined
- Jan 8, 2016
- Messages
- 598
- Office Version
- 2019
- Platform
- Windows
hi guys-
I built a macro where i move pivot table columns around as one of the last steps. (First time automating a pivot table).
The report has financial info, so like "Current", "120+", "180+"
however, if the data doesnt have one of those statuses, the Macro errors out because it cant find that pivot table field. How can i work around and have the macro skip over if that status is not available?
I built a macro where i move pivot table columns around as one of the last steps. (First time automating a pivot table).
The report has financial info, so like "Current", "120+", "180+"
however, if the data doesnt have one of those statuses, the Macro errors out because it cant find that pivot table field. How can i work around and have the macro skip over if that status is not available?
VBA Code:
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Pro Num"), "Count of Pro Num", xlCount
Range("H2").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Age Bucket").PivotItems( _
"Current").Position = 1
Range("C2").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Age Bucket").PivotItems( _
"120+").Position = 7
Range("D2").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Age Bucket").PivotItems( _
"180+").Position = 7