Hello,
I have a macro that controls 3 different pivot tables for me. It works fine as long as the filter "term" is in the data. The data gets updated monthly and sometimes some of the "terms" that I use to filter with won't have any data for a given month.
When this happens I get the 1004: run-time error Application-defined or object-defined error, due to the Filter "term" being absent.
here's my code...
In this example, if there were no data points in a given month for MXG, then "MXG" will not be in the pivot table to picked, causing the error.
I'd like for it to pick "(blank)" in the absence of "MXG" because "(blank)" is always available.
I'd need it to do this for all 3 pivot tables separately.
I have a macro that controls 3 different pivot tables for me. It works fine as long as the filter "term" is in the data. The data gets updated monthly and sometimes some of the "terms" that I use to filter with won't have any data for a given month.
When this happens I get the 1004: run-time error Application-defined or object-defined error, due to the Filter "term" being absent.
here's my code...
VBA Code:
Sub MXG()
'
' MXG Macro
' Get MXG Data
'
'
Sheets("My Data").Select
ActiveSheet.PivotTables("PivotTable13").PivotFields("Work Center"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable13").PivotFields("Work Center").CurrentPage _
= "MXG"
ActiveSheet.PivotTables("PivotTable14").PivotFields("Org").ClearAllFilters
ActiveSheet.PivotTables("PivotTable14").PivotFields("Org").CurrentPage = "MXG"
ActiveSheet.PivotTables("PivotTable15").PivotFields("Org").ClearAllFilters
ActiveSheet.PivotTables("PivotTable15").PivotFields("Org").CurrentPage = "MXG"
End Sub
I'd like for it to pick "(blank)" in the absence of "MXG" because "(blank)" is always available.
I'd need it to do this for all 3 pivot tables separately.