I am trying to make a macro that will automaticly adjust the filters for several pivot tables based on user input, however if the user puts in something that isn't avaialble the code produces an error when trying to apply the filter.
Is there anyway to check which filters are available to select?
Example: One pivot table has three filters available (Year, Month, Type [Complaint, Praise, Both]) but if during a month there weren't any complaints then there is an error.
Code:
With PTable
.PivotFields("Year").CurrentPage = Y
.PivotFields("Month").CurrentPage = M
.PivotFields("Type").CurrentPage = T 'Error line if T isn't valid
End With
On Error Resume NextandOn Error GoTo 0err.clearjust before the line, and checkerr.Numberafter. 0 is no error, anything else is an error