I have 2 pivot tables with one header/information identical. I need to control the filtering of the pivot table field(s) with a combo box. I have already added filled my combo box with the necessary information but cannot control the pivot table with the combo box selection.
I have tried multiple code. Please help. Current code... I have also tried activeworksheet("Dashboard").Pivottables("Actual").pivotfields("Building_COID").CurrentPage = Range("AK2")
Sub Combo_Change()
Dim pvtTable As PivotTable
Dim pvtField As PivotField
Dim pvtItem As PivotItem
Dim filterName As String
On Error Resume Next
Set pvtTable = Worksheets("Dashboard").PivotTables("Actual")
Set pvtField = pvtTable.PivotFields("Building_COID")
filterName = Worksheets("Dashboard").Range("Building_COID")
For Each pvtItem In pvtField.PivotItems
If pvtItem.Value = "(All)" Then
pvtField.CurrentPage = "(All)"
Else
pvtField.CurrentPage = filterName
Exit For
End If
Next pvtItem
Bookmarks