Hi all,
I want to achieve the following: have a pivot table update based on a change in a cell. This cell is being populated based on another cell.
I have been trying multiple options for the 'cell controlled pivot filter' over and over. Thought I had it in a test file but when I use it in my final file it bugs again. The issue occurs at this point: Field.CurrentPage = NewCat.
Any assistance is very much appreciated.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'This line stops the worksheet updating on every change, it only updates when cell
'H6 or H7 is touched
If Intersect(Target, Range("D1:D2")) Is Nothing Then Exit Sub
'Set the Variables to be used
Dim pt As PivotTable
Dim Field As PivotField
Dim NewCat As String
'Here you amend to suit your data
Set pt = Worksheets("Sheet1").PivotTables("PivotTable4")
Set Field = pt.PivotFields("Priced_product")
NewCat = Worksheets("Sheet1").Range("D1").Value
'This updates and refreshes the PIVOT table
With pt
Field.ClearAllFilters
Field.CurrentPage = NewCat
pt.RefreshTable
End With
End Sub
I want to achieve the following: have a pivot table update based on a change in a cell. This cell is being populated based on another cell.
I have been trying multiple options for the 'cell controlled pivot filter' over and over. Thought I had it in a test file but when I use it in my final file it bugs again. The issue occurs at this point: Field.CurrentPage = NewCat.
Any assistance is very much appreciated.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'This line stops the worksheet updating on every change, it only updates when cell
'H6 or H7 is touched
If Intersect(Target, Range("D1:D2")) Is Nothing Then Exit Sub
'Set the Variables to be used
Dim pt As PivotTable
Dim Field As PivotField
Dim NewCat As String
'Here you amend to suit your data
Set pt = Worksheets("Sheet1").PivotTables("PivotTable4")
Set Field = pt.PivotFields("Priced_product")
NewCat = Worksheets("Sheet1").Range("D1").Value
'This updates and refreshes the PIVOT table
With pt
Field.ClearAllFilters
Field.CurrentPage = NewCat
pt.RefreshTable
End With
End Sub