Hi Guys,
I've been looking around for the answer and found partial answer here:
Forum > Microsoft Office Application Help - Excel Help forum > Excel Programming > Change Pivot Table Filter Based on Cell Value.
The answer posted by T-J was:
Sub Apply_Date_Filter_From_Worksheet()
Dim pvtTable As PivotTable
Dim pvtField As PivotField
Dim pvtItem As PivotItem
Dim filterDate As Date
Set pvtTable = Worksheets("Pivot_Sheet").PivotTables("PivotTable1")
Set pvtField = pvtTable.PivotFields("Date")
filterDate = CDate(Worksheets("Controls_Sheet").Range("B2"))
On Error Resume Next 'in case date not found
For Each pvtItem In pvtField.PivotItems
If CDate(pvtItem.Value) = filterDate Then
pvtItem.Visible = True
Else
pvtItem.Visible = False
End If
Next pvtItem
End Sub
I can adapt this to my workbook & it works okay, but I need to change the filter to a number of different values in a list, some of which might not be available in the data.
Background :
I'm taking 14,000 entries of Incident data & pivoting the incidents based on where they were resolved, the filter will be based on which resolution group has been given a 'tag' of Onsite/Remote/Customer, these would each have their own tab creating the list i'd like to pivot from.
I need the pivot to display all incidents resolved by resolution groups 'tagged' as onsite (I.e. all those groups in list one on Sheet 'Onsite')
These may not all be present in the incident data, i dont know if that will cause errors if it attmempts to set the filter to something that isnt there...
Bookmarks