Note that there are some explanatory texts on larger screens.

plurals
  1. POFiltering a Pivot Table Automatically in Excel
    text
    copied!<p>I'm building a DB for school activities in the afternoon. I'm trying to create a search option through a form that controls a pivot table in which the user can filter on the class type and/or the age group and or the school year.</p> <p>I wrote this code in VBA and it's not working. When i tried to write a code to filter on only one of the above (such as class type) it worked but when I expanded it to 3 filter options it isn't working. It fails when no value is inserted in one of the options.</p> <pre><code>search_class.Hide ActiveSheet.PivotTables("PivotSearchClass").PivotFields("class type").ClearAllFilters If IsNull(Range("type_search").Value) Then ActiveSheet.PivotTables("PivotSearchClass").PivotFields("class type").CurrentPage = "(All)" Else: ActiveSheet.PivotTables("PivotSearchClass").PivotFields("class type").CurrentPage = Range("type_search").Value End If type_box = "pick a class type" ActiveSheet.PivotTables("PivotSearchClass").PivotFields("group age").ClearAllFilters If IsNull(Range("target_search").Value) Then ActiveSheet.PivotTables("PivotSearchClass").PivotFields("group age").CurrentPage = "(All)" Else: ActiveSheet.PivotTables("PivotSearchClass").PivotFields("group age").CurrentPage = Range("target_search").Value End If target_box = "pick a group age" ActiveSheet.PivotTables("PivotSearchClass").PivotFields("school year").ClearAllFilters If IsNull(Range("year_search").Value) Then ActiveSheet.PivotTables("PivotSearchClass").PivotFields("school year").CurrentPage = "(All)" Else: ActiveSheet.PivotTables("PivotSearchClass").PivotFields("school year").CurrentPage = Range("year_search").Value End If year_search_box = "pick a school year" ActiveSheet.PivotTables("PivotSearchClass").PivotCache.Refresh </code></pre> <p>Does anyone know ehat the problem is and how to fix it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload