sanantonio
Board Regular
- Joined
- Oct 26, 2021
- Messages
- 124
- Office Version
- 365
- Platform
- Windows
VBA Code:
Sub FilterPivot_SingleCell()
Dim PV_WS As Worksheet
Dim Pv_Table As PivotTable
Dim Pv_Field As PivotField
Dim Fltr_KW As String
'Assigning Worksheet of Pivot Table
Set PV_WS = Worksheets("Report")
'Assigning PivotTable Name
Set Pv_Table = PV_WS.PivotTables("PivotTable12")
'Assigning PivotTable Field to Filter
Set Pv_Field = Pv_Table.PivotFields("Short")
'Assigning Cell Value to the Filter KeyWord
Fltr_KW = Range("B3").Value
'Clearing all filters
Pv_Field.ClearAllFilters
'Setting Filters to the cell value
Pv_Field.CurrentPage = Fltr_KW
End Sub
My pivot table name is correct, and it's on the worksheet called "Report", the filter is called "Short" and there is a value in B3.
I've had the code in "This Workbook", in the "Report" worksheet and in a module and it just doesn't seem to work.
I've had a similar macro to this working some years ago but I can't find my version so this has come from a quick google but it doesn't seem to work.
Any ideas?